Spring boot内置.jar Mojarra没有初始化

时间:2015-05-18 12:02:40

标签: spring maven jsf spring-boot

当运行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没有被添加到弹簧启动中,因此错误成为理所当然的事。

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

如何让我的mvn clean package正确添加jsf-impl和jsf-api以便Mojarra将在我的Spring启动项目中运行?下面是我的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行的Mojarra启动-45

1 个答案:

答案 0 :(得分:0)

我终于找到了解决方法!

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

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

如果你有这个问题,祝你好运,这是一个复杂的问题。