java.lang.IllegalStateException: No Factories configured for this Application - jsf

I changed the way an application was being built. It was being built by maven earlier, I changed it to ANT.
After the change, I started getting the following error:
java.lang.IllegalStateException: No Factories configured for this Application.
This happens if the faces-initialization does not work at all - make sure that you
properly include all configuration settings necessary for a basic faces application
and that all the necessary libs are included.
Also check the logging output of your web application and your container for
any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this:
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
javax.faces.FactoryFinder._getFactory(FactoryFinder.java:246)
javax.faces.FactoryFinder.getFactory(FactoryFinder.java:200)
javax.faces.webapp.FacesServlet.init(FacesServlet.java:112)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
java.lang.Thread.run(Thread.java:662)
The web.xml does not have the following:
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
But since the application was working without it earlier, I am thinking this is some other issue. I looked up for this issue in google and most of them suggest it could be because of compatibility issue with Tomcat jar (servlet-api.jar, el-api.jar, jsp-api.jar). I couldn't remove el-api.jar as it is being used by the application.
This seems to be some dependency / libraries issue.

Related

Netbeans 12 Hot Deployment to Wildfly 16

I'm having a lot of issues getting Netbeans 12 to hot deploy a JavaEE project (using Ant) to Wildfly. Surprisingly, any changes to my Java code hot deploys as usual upon save, but any changes to my web markup (.xhtml) will only show up after a fresh deployment.
Here's a list of what I've done and my current settings:
Settings:
Copy Static Resources on Save
Compile on Save
In my web.xml:
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
What I've tried:
Reviewed the following questions and applied changes where applicable (most was not applicable given my version of Wildfly)
How do I enable on-the-fly compilation of JSPs in Wildfly 9?
https://developer.jboss.org/thread/237954
Netbeans 8.2 + wildfly 11 hot deploy not working [I've had this issue in NetBeans 8.2 instances too! No resolution]
Wildfly system Property:
<system-properties>
<property name="java.net.preferIPv4Stack" value="true"/>
<property name="org.jboss.as.web.deployment.DELETE_WORK_DIR_ONCONTEXTDESTROY" value="true"/>
</system-properties>
Wildfly Deployment Scanner:
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir"
scan-interval="100"
auto-deploy-exploded="true"
untime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
</subsystem>
In addition to the above, I've also modified the Ant script to copy the required files over to the appropriate directories. This DOES work, but each time I do this, I lose any session state with the app that I had prior to the save.
What I'm hoping to achieve is to be able to modify either my backing Java code or my front-end markup and upon saving the file (or clicking the hot deploy button, doesn't really matter to me) have the changes reflected on my application server.
I've worked on other projects that used WebLogic as the application server with no issues. Netbeans (8) simply "works" when you attach the debugger and modify a file (using WebLogic). The changes are immediately reflected in the browser upon a refresh without loss of state. I'm hoping that I'm missing something really small and it's easy to do with Netbeans 12 + Wildfly as well.
Thank you!! Hopefully I'm just missing something small!

Log4j Class missing on Weblogic

I have deployed a war file on Oracle Weblogic. War files contain all the required libraries in WEB-INF/lib. But whenever I am trying to visit my webpage, it gives error of
java.lang.NoClassDefFoundError: org/apache/log4j/Logger.
try adding to weblogic.xml :
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
(Although this may cause secondary issues with JSF jar's.)
The problem is resolved. One of my custom library using log4j, that one was not able to find log4j. So I created the jar including log4j and its working.

Shared library with newer version of MyFaces on WebSphere 8.5

I'm migrating applications from WebSphere 7.0 to WebSphere 8.5. WebSphere 8.5 uses older version of MyFaces (2.0.2) than we use (2.0.7) so I've tried to configure the newer version in the same way as under WAS 7.0, that is, using shared library.
I've configured shared library with the following jars:
myfaces-api-2.0.7.jar
myfaces-impl-2.0.7.jar
commons-logging-1.1.1.jar
commons-digester-1.8.jar
commons-collections-3.2.jar
commons-codec-1.3.jar
I've checked the option Use an isolated class loader for this shared library . I've got the error:
com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E:
[Servlet Error]-[Faces Servlet]: java.lang.IllegalStateException: No
Factories configured for this Application. This happens if the
faces-initialization does not work at all - make sure that you
properly include all configuration settings necessary for a basic
faces application and that all the necessary libs are included. Also
check the logging output of your web application and your container
for any exceptions! If you did that and find nothing, the mistake
might be due to the fact that you use some special web-containers
which do not support registering context-listeners via TLD files and a
context listener is not setup in your web.xml. A typical config looks
like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:196) at
javax.faces.webapp.FacesServlet.init(FacesServlet.java:112) at
com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:337)
The same configuration worked on WAS 7.0, with the exception that there was an additional jar configured in the shared library:
C:\IBM\SDP\runtimes\base_v7\optionalLibraries\IBM\JSFProviders\WebSphere-MyFaces20-annotation-provider.jar
What is wrong here? Do I need to specify something in place of that WebSphere-MyFaces20-annotation-provider.jar? I wasn't able to find any example of configuring such shared library for WAS 8.5. There's only that for WAS 7.0, that I've used successfully on WAS 7.0.
There is some related discussion in the WASdev forum but apparently no actual answer yet.
https://www.ibm.com/developerworks/community/forums/html/topic?id=d2261080-de03-4aef-97ce-b60c5b8a517b&ps=25

How To Execute Solr Commit Before Closing The Web App?

Everyone. I Face A Problem In Solr Using, In Development Environment, Project Always Close And Start, Start And Close, When We Stop Tomcat, Some Solr Documents Are Remained Not Committed. How To Overcome This Headache, Can Anyone Show Some Ideas? Great Thanx.....
You can use a shutdown hook within your webapplication to handle the shutdowns and commit the data.
Use a class that implements ServletContextListener in your web.xml:
<web-app>
<!-- Usual stuff here -->
<listener>
<listener-class>solr.commitListerner</listener-class>
</listener>
</web-app>

How to override server jar with ones from WEB-INF/lib or use them instead?

i have Web Application which should use JSF 2.0 libraries included in WEB-INF/lib... but it does not... instead of i'm getting exception because my server (JBoss 4.2) also provides JSF libraries...
How can i force my application to use .jar's from WEB-INF/lib ?
Note: When i removed JSF libs from server, my application runs as it should.
Tell JBoss that your WAR already bundles JSF by the following entry in your webapp's web.xml.
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
Why can't you use the server versions of those JARs?
You should be writing and testing your application using the same versions of the JARs that the server you deploy to is using. Synch up....I'd either upgrade JBOSS or downgrade your app.
But, if you must, perhaps this document can tell you how:
http://www.datadisk.co.uk/html_docs/java_app/jboss5/jboss5_deployment.htm

Resources