ViewExpiredException in JSF while upgrading Tomcat on cluster - jsf

I upgraded a Tomcat 7.0.27 to Tomcat 7.0.57 and the Tomcat is in cluster environment. After upgraded, the Tomcat in cluster, we are getting ViewExpiredException, didn't get in previous version in cluster.
Added state saving method to client but still not working
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
Tried by using error-page tag
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/faces/login.xhtml</location>
</error-page>
It's also not working.
If, when we stopped any one of the server, it's working fine. when ever we bring up the another server getting this issue and the first time only getting this issue, if we reloaded the page, it's working fine.
Strange is, code working fine in Tomcat 7.0.27,
Any suggestions please.

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!

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

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.

Is there com.sun.faces.enableAgressiveSessionDirtying for view scope?

The following config parameter in web.xml causes the #SessionScoped managed beans to replicate across a cluster:
<context-param>
<param-name>com.sun.faces.enableAgressiveSessionDirtying</param-name>
<param-value>true</param-value>
</context-param>
Is there some parameter like enableAgressiveViewDirtying? According to the comments here it is not possible to replicate #ViewScoped state across a cluster. Is this true? I am using Weblogic 10.3.6 with Mojarra 2.1.2. Could it be implementation-specific? If I switched to CDI, would there be a chance it would work better?
This answer claims a listener can do it. However, I could not get it to work.
This is a Mojarra bug: https://java.net/jira/browse/GLASSFISH-20279. Currently #ViewScoped is not replicated in a cluster.

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