Error deploying JSF app in Glassfish - jsf

I used to deploy a JSF+Primefaces app in a Glassfish server without any trouble. Recently I upgraded my NetBeans version. I haven't had any problems with the most of the applications after that. But with one of them when I tried to do the deployment, it failed and this was the error message:
Error occurred during deployment: Exception while loading the app :
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: java.lang.RuntimeException:
com.sun.faces.config.ConfigurationException:
java.util.concurrent.ExecutionException:
com.sun.faces.config.ConfigurationException: Unable to parse document
'jar:file:/opt/glassfish3/glassfish/domains/domain1/applications/[name-of-the-application]/WEB-INF/lib/javax.faces.jar!/META-INF/mojarra_ext.taglib.xml':
null. Please see server.log for more details.
It seems like all is ok with the project (cleans and build well), but the error keeps appearing. This is the environment I'm using:
NetBeans 7.3.1
JSF 2.2 (Mojarra)
GlassFish Open Source Edition 3.1.1 (build 12).
PS: When I try to do the deployment with Glassfish 3 bundled in NetBeans, this is the error:
SEVERE: Error during deployment : class com.sun.faces.application.annotation.PersistenceUnit Scanner cannot access its superinterface com.sun.faces.application.annotation.Scanner
Thanks

Unable to parse document 'jar:file:/opt/glassfish3/glassfish/domains/domain1/applications/[name-of-the-application]/WEB-INF/lib/javax.faces.jar!/META-INF/mojarra_ext.taglib.xml
The path to the taglib file suggests that you shipped JSF 2.2 along with the webapp inside its /WEB-INF/lib instead of upgrading GlassFish itself. As GlassFish 3 itself ships with a JSF 2.1 implementation out the box, you need to instruct it to not load it in order to avoid version conflicts. You didn't state anywhere that you were doing that, so I guess that this is the whole cause of your problem.
Glassfish itself already ships with JSF bundled which get by default classloading precedence over the one bundled in the webapp. You basically need to tell Glassfish to use the webapp bundled JSF instead.
In order to achieve that, edit the /WEB-INF/glassfish-web.xml to add the following two lines.
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
If the file does not exist create it, you can find a sample xml file here. and add the two lines from above inside the <glassfish-web-app> tag.
GlassFish will then suppress its own bundled JSF from loading and rely on webapp-bundled JSF.
Alternatively, if you have full admin control over Glassfish, you can also copy the javax.faces.jar file from JSF 2.2 into the /glassfish/modules directory, hereby replacing the old one, in order to upgrade it from JSF 2.1 to JSF 2.2 so that it get applied on all webapps.

Related

java.lang.NullPointerException at org.omnifaces.cdi.eager.EagerBeansWebListener.requestInitialized

I am using TomEE Plus 1.7.2 Server and try to start a webapp with OmniFaces included, but I get a Nullpointer exception:
WARNUNG: Could not instantiate eager request scoped beans for request /index.xhtml. Possibly the CDI request scope is not active. If this is indeed the case, see JavaDoc on org.omnifaces.cdi.Eager on how to remedy this.
java.lang.NullPointerException
at org.omnifaces.cdi.eager.EagerBeansWebListener.requestInitialized(EagerBeansWebListener.java:78)
When I use the EagerBeansFilter as shown at OmniFaces docs, I get a slight variation:
WARNUNG: Could not instantiate eager application scoped beans. Possibly the CDI application scope is not active. This is known to be the case in certain Tomcat and Jetty based configurations.
java.lang.NullPointerException
at org.omnifaces.cdi.eager.EagerBeansRepository.instantiateApplicationScopedAndRegisterListener(EagerBeansRepository.java:69)
Is this server not combinable with omnifaces?
TomEE is after WildFly one of most tested servers for OmniFaces, particularly because it uses almost everywhere in Java EE a different implementation as compared to WildFly (Apache vs Oracle). In the OmniFaces compatibility matrix you can find TomEE versions which successfully ran through all pages in OmniFaces showcase.
Those exceptions mentioned in your question will be thrown when CDI BeanManager couldn't find the OmniFaces EagerBeansRepository, which is an #ApplicationScoped bean. This in turn indicates a misconfigured CDI environment (e.g. wrong beans.xml or missing JNDI/listener configuration) or a dirty build (e.g. duplicate libraries). Verifying the CDI configuration and performing a full clean/rebuild should solve the problem.
At least, OmniFaces 2.2 or newer is technically incompatible with TomEE 1.x, because TomEE 1.x ships with JSF 2.1 and OmniFaces 2.2 or newer has a hard dependency on JSF 2.2 due to new <o:viewAction> tag. So, unless you modify TomEE to provide JSF 2.2, OmniFaces 2.2 or newer won't deploy and should fail deployment with below exception:
java.lang.NoClassDefFoundError: javax/faces/component/UIViewAction
The latest OmniFaces version which successfully deploys on a stock TomEE 1.7.x server is OmniFaces 2.1. If you want to use OmniFaces 2.2 or newer on a stock TomEE, then you need to upgrade to TomEE 7.x.

jsf facelets cannot find property in tomcat 7 but works in glassfish 3.1

I am trying to figure out which jar I need to download for tomcat 7. I am making a call and passing an argument to a method such "availableEmployees(DepartmentName)" in my faces web page. This does not work in tomcat 7 but works in glassfish 3.1. I have added the javax.faces.2.1.20.jar "Mojarra" to my web app for jsf dependency. I have also javax.servlet.jsp.jstl.1.2.1 in my tomcat library folder.
Did anyone run into such problem ? Do I need to add more than the above jars for jsf support ? Thanks. Not using maven since it is somebody else' project.
I am using netbeans and I linked to an eclipse project. I added my own primefaces library. When I looked at the build output from netbeans, I have noticed that there were two copies of primefaces library. One with 3.4.2 and another with 3.3.1.
Removed one of them and everything worked.

Richfaces 3.3.3.final jar and jsf 1.2 deployment fails on WAS7

I want to migrate from richfaces 3.3.1 to 3.3.3.Final jar for rich:scrollabledatatable issues (header disappears after rerender).
I am using jsf 1.2. After successfully building the application through maven,I deployed build of my applicaiton on WAS 7, i am getting error saying Deployment failed:
ADMA5069E : The installation of App failed.
If anyone has done migration to 3.3.3.Final, please suggest if apart from pom.xml version change anything else needs to be done.All other web.xml entries etc are same as when i used 3.3.1 richfaces version.

How do I upgrade the JSF API in GlassFish?

I downloaded binary which has javax.faces-2.1.13 as the latest binary release. I want to upgrade my GlassFish JSF library but it has jsf-api-jar and other impl. How do I update and where do I download the jars?
Just replace both jsf-api.jar and jsf-impl.jar in the Glassfish /modules folder by the single javax.faces.jar file.
Since Mojarra 2.1.6 the build system has been changed to comply Java EE Maven rules, see also issue 2028. This resulted in the API and impl being merged into a single JAR file.
if you having some issues after replacing faces files in glassfish/modules folder, like non-compatibility of you framework version with jsf 2.2,2.3 and etc (for example "icefaces 4.1.1 error 200 during update: javax.faces.viewstate not found") or some unexpected behaviour - dont forget to clean glassfish/domains/somedomain/osgi-cache

JSF External Context getRealPath

I'm using JSF 2.1.2.
On my locale machine
FacesContext.getCurrentInstance().getExternalContext().getRealPath("navigation.xml")
returns the correct path to the file!
On another machine it returns null.
I deployed the same WAR file on both machines.
Both are running a Weblogic Server 10.3.5
The JSF libraries are in the WEB-INF/libs folder, I'm not using the version shipped with weblogic.
Any idea why this does not work?
Any other proposal how I can get the path to the file, so that I don't have to call getRealPath?
EDIT: I switched to JSF 2.0.6. Because JSF 2.1 requires Java Servlet 3.0, which is not yet supported by Weblogic. But the error is still the same...

Resources