【问题标题】:Spring boot built .jar Mojarra not InitializingSpring Boot 构建的 .jar Mojarra 未初始化
【发布时间】:2015-07-29 22:17:45
【问题描述】:

当运行mvn clean package 并使用java -jar application.jar 通过我的终端部署时,我的应用程序将无法运行,抛出java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory.,但在直接运行应用程序时会运行 (Application.java -> Run main())

我可能已经找到了原因,现在我需要学习如何解决它。相关行是:

INFO 7556 --- [ost-startStop-1] j.e.resource.webcontainer.jsf.config : Initializing Mojarra 2.2.11 ( 20150505-0732 https://svn.java.net/svn/mojarra~svn/tags/2.2.11@14688) for context ''

此行在运行 Application.java 时会显示出来,但不会出现在 java -jar application.jar 输出中。我相信这会导致我出现 ApplicationFactory 错误,在这种情况下实际上是正确的,它真的根本找不到 ApplicationFactory!

所以我一直在谷歌搜索如何解决应用程序抛出的java.lang.IllegalStateException [...] javax.faces.application.ApplicationFactory.,并了解到它可能是由于污染的 jsf-impl/jsf-api 或配置错误的 javax 面而引发的。

但是,有了这个新发现,我发现由于 Mojarra 2.2.11 没有被添加到 spring-boot 中,因此错误变得理所当然。

这是a question I still haven't solved,在同一个问题上,但是这个发现完全改变了错误本身的范围,以及如何修复它的方法。

知道如何让我的mvn clean package 正确添加 jsf-impl 和 jsf-api 以便 Mojarra 可以在我的 Spring Boot 项目中运行吗?下面是我的 pom.xml

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>iSAP</groupId>
    <artifactId>CFDI</artifactId>
    <version>0.3</version>
    <inceptionYear>2015</inceptionYear>
    <packaging>jar</packaging>

    <name>recepcion-cfdi</name>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.3.RELEASE</version>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java-version>1.8</java-version>
        <io.spring.platform-version>1.1.2.RELEASE</io.spring.platform-version>
        <!-- AssertJ is not a part of Spring IO platform, so the version must be provided explicitly -->
        <assertj-core-version>1.5.0</assertj-core-version>
        <tomcat.version>8.0.21</tomcat.version>
        <start-class>com.isap.config.Application</start-class>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>${io.spring.platform-version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- PRIMEFACES -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>5.2</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>bootstrap</artifactId>
            <version>1.0.10</version>
        </dependency>
        <!-- /PRIMEFACES -->

        <!-- Tomcat -->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-core</artifactId>
            <version>8.0.21</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-logging-juli</artifactId>
            <version>8.0.21</version>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <version>8.0.21</version>
        </dependency>
        <!-- /Tomcat -->

        <!-- Microsoft JDBC -->
        <!-- NOTE: This is saved locally in the /lib folder.
             Microsoft doesn't allow maven to have it in a public repository. -->
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>sqljdbc41</artifactId>
            <version>4.1</version>
            <!-- These two lines are edited out when the local repo is installed, if you don't
             have JDBC installed locally you should unedit these two lines -->
            <!--<scope>system</scope>-->
            <!--<systemPath>${basedir}/lib/sqljdbc41.jar</systemPath>-->
        </dependency>

        <!-- /Microsoft JDBC -->

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.1.3.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.9.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.3.9.Final</version>
        </dependency>
        <!-- /Hibernate -->

        <!-- Prettyfaces -->
        <dependency>
            <groupId>com.ocpsoft</groupId>
            <artifactId>prettyfaces-jsf2</artifactId>
            <version>3.3.3</version>
        </dependency>
        <!-- /Prettyfaces -->

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

        <!-- Utilities -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>

        <!-- Core -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.11</version>
            <!--<scope>compile</scope>-->
        </dependency>

        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.11</version>
            <!--<scope>compile</scope>-->
        </dependency>
        <!-- /Core -->

        <!-- Imported for CFDI -->
        <dependency>
            <groupId>mx.bigdata.cfdi</groupId>
            <artifactId>cfdi-base</artifactId>
            <version>0.2.5</version>
        </dependency>
        <!-- /Imported for CFDI -->

        <!-- Imported for validacionCFDI -->
        <!-- JDOM -->
        <dependency>
            <groupId>jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>1.1</version>
        </dependency>
        <!-- /JDOM -->

        <!-- Xerces -->
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xerces</artifactId>
            <version>2.4.0</version>
        </dependency>
        <!-- /Xerces -->

        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.11.0</version>
        </dependency>
        <!-- Imported for validacionCFDI -->



    </dependencies>

    <build>
        <outputDirectory>src/main/webapp/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <name>Spring Releases</name>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>
</project>

这是正在运行的 Application.java 的 pastebin,Mojarra 出现的行是第 29 行。这里是 pastebin,Spring-boot 在第 44-45 行没有显示 Mojarra 启动。

【问题讨论】:

    标签: spring maven jsf spring-boot


    【解决方案1】:

    我终于找到了解决方法!

    我找到了this github issue.,它详细说明了为什么它在 IntelliJ 中而不是在 Spring Boot 中运行。

    按照里面的说明,包括对我的 Application.java 的一些修改,以及其中的一些其他内容,我得到了一些工作。

    如果您遇到此问题,祝您好运,这是一个复杂的问题。

    【讨论】:

      猜你喜欢
      • 2018-05-29
      • 2020-12-14
      • 2018-02-14
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      • 2017-12-10
      • 2017-03-28
      • 2018-03-22
      相关资源
      最近更新 更多