Reputation: 2608
When running a mvn clean package
and deploying through my terminal with java -jar application.jar
my application will not run, throwing a java.lang.IllegalStateException: Could not find backup for factory javax.faces.application.ApplicationFactory.
but will run when running the application directly (Application.java -> Run main()
)
I might have found the reason, now I need to learn how to fix it. The relevant line is:
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 ''
This line shows itself when running the Application.java, but doesn't appear in the java -jar application.jar
output. Which I believe leads me to the ApplicationFactory error, which is actually correct in this instance, it really cannot find an ApplicationFactory at all!
So I had been googling how to resolve java.lang.IllegalStateException [...] javax.faces.application.ApplicationFactory.
which is what the application throws, and learned that it could be thrown due to a polluted jsf-impl/jsf-api, or a misconfigured javax faces.
However, with this new discovery I found out that since Mojarra 2.2.11 isn't getting added to the spring-boot, the error becomes a matter of course.
This is a question I still haven't solved, on the same issue, however this discovery completely changes the scope of the error itself, and the approach as to how to fix it.
Any idea of how I can make my mvn clean package
properly add jsf-impl and jsf-api so that Mojarra will run in my Spring boot project? Below is my 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>
Here is a pastebin of the Application.java being run, the line where Mojarra appears is line 29. And here is a pastebin with the Spring-boot not showing the Mojarra startup on lines 44-45.
Upvotes: 0
Views: 998
Reputation: 2608
I finally found how to fix it!
I found this github issue. Which detailed why it was running in IntelliJ and not in Spring Boot.
Following intructions inside, including some modifications to my Application.java, and a few others in there and I got stuff working.
Best of luck if you have this issue, it's a complicated one.
Upvotes: 1