Spring 启动构建的 .jar Mojarra 未初始化
Spring boot built .jar Mojarra not Initializing
当 运行使用 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 引导项目中吗?下面是我的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>
这是 pastebin of the Application.java being run, the line where Mojarra appears is line 29. And here is a pastebin,Spring-boot 在第 44-45 行不显示 Mojarra 启动。
我终于找到了解决方法!
我发现 this github issue. 详细说明了为什么它在 IntelliJ 中是 运行 而在 Spring Boot 中不是。
按照内部说明进行操作,包括对我的 Application.java 和其他一些内容进行一些修改,我开始工作了。
如果你遇到这个问题,祝你好运,这是一个复杂的问题。
当 运行使用 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 引导项目中吗?下面是我的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>
这是 pastebin of the Application.java being run, the line where Mojarra appears is line 29. And here is a pastebin,Spring-boot 在第 44-45 行不显示 Mojarra 启动。
我终于找到了解决方法!
我发现 this github issue. 详细说明了为什么它在 IntelliJ 中是 运行 而在 Spring Boot 中不是。
按照内部说明进行操作,包括对我的 Application.java 和其他一些内容进行一些修改,我开始工作了。
如果你遇到这个问题,祝你好运,这是一个复杂的问题。