JNDI Error on JSF 2.0 Migration - jsf-2

We are migrating our application from JSF (MyFaces, Trinidad) 1.2 to JSF (MyFaces, Trinidad) 2.0. I have done the all basic changes like updating the XMLNS for Faces-Config, updating the Web.xml to support 3.0, removed Facelets, el-api, el-ri Jars.
When I set the classloaderMode to PARENT_LAST in Websphere 8.5.5 for picking our MyFaces & Trinidad jar, I'm getting the below error.
A java: URL name was used, but Naming was not configured to handle java: URL names. The likely cause is a user in error attempting to specify a java: URL name in a non-J2EE client or server environment. Throwing ConfigurationException
But I'm NOT getting the same exception when I set the classloaderMode to PARENT_FIRST. How can I resolve this problem? Please help me.

The error sounds like you have include WAS JNDI classes in your WAR, which when combined with PARENT_LAST causes the JDK JNDI to use those uninitialized classes rather than the ones included with WAS. You should not repackage WAS JARs in your application.

Related

JSF2 and primefaces 3.4 on Websphere 8

I have created web dynamic project with jsf2, Primefaces 3.4, Tomcat7.Application runs fine. If i deploy the EAR of the same project on Websphere8 instead of Tomcat7, I am getting Exceptions.I am not sure of what is happening. I am new to JSF2 and Wepshere8.
can you provide me the links on how to start sample jsf2 + primefaces project on Websphere 8
Thanks in advance.
Got it. Try to add com.sun.faces.config.ConfigureListener instead of org.apache.myfaces.webapp.StartupServletContextListener in your web.xml, restart your server and then run it.
The code should look like the following.
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
For using different implementations of JSF, the WebSphere Application Server JSF engine determines if the SUN RI or Apache MyFaces is used from the application server run time. After the JSF engine determines the implementation that is used, the correct listener class is registered with the web container. You do not need to add the com.sun.faces.ConfigureListener or the org.apache.myfaces.StartupConfigureListener to the web.xml file.
http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.0.0/com.ibm.websphere.nd.doc/info/ae/ae/cweb_javaserver_faces.html
Please see above...
I too faced the same problem.
Websphere by default support sun impl and apache myfaces and its jsf 1.2.
To use jsf 2 implementation.
1.Make sure to remove servlet.jar from your application.Its need for tomcat however not in websphere.
2.Change the classloader policy for ear to parent last.Parent last means lib in your app will have higher priority.if not found will load from WAS class path.
3.Also make sure to change the webmodule class loader policy to parent last.
4.Restart websphere.
To solve the classloader of primefaces in websphere 8.5 classes replace the jsf
jsf-api
jsf-impl
javaee-api
for the native implementation of websphere
myfaces-api
myfaces-impl

JSF 2 and Websphere 7.0 don't want to run

I am having some trouble with JSF2 and websphere 7.0. I have searched in the internet but nothing. The thing looks to be that websphere puts its 1.2 libraries and override my 2.0 libs. The app is working fine in apache-tomcat
Thirst of all, when i try to get an xhtml page (with simple html the app works, the problem is with jsf) the server shows the error:
could not find factory: javax.faces.context.FacesContextFactory
i've read that i had to use the "parent last" option in the class loader section, but it didn't worked. Then i went to jsp and jsf options on the web module properties, and there i can choose between Sun reference implementation 1.2 and MyFaces 1.2, the sun was selected, so i choose myfaces and now the error is another one: if i try to go to "something.xhtml", it redirects to "something.jsf", which doesn't exists..
any idea?
thanks!
It seems that you didn't include the JSF implementation on your classpath.
Here's how I solved it.
Use the following library: javax.faces-2.1.7.jar
If you are on PrimeFaces 3.1: primefaces-3.1.1.jar
Application Server instance: Class Loading - Parent Last
Enterprise Application instance (war Module): Class Loading - Parent Last
Make sure to remove all Servlet Container libraries such as those needed by Tomcat.

JSF 2 Mojarra and Primefaces in WebSphere 7+

I have been struggling with the unholy alliance that is WebSphere 7+ and Mojarra 2.0.4 and have run into something of a showstopper.
I followed the directions as specified at this forum post and got Mojarra 2.0.4 initializing properly: http://forum.primefaces.org/viewtopic.php?f=3&t=6860
Basically I created an isolated classloader shared library that refers externally to the Mojarra and Primefaces jars, added the shared library to the webapp and reversed the classloader to go PARENT_LAST. All of that works.
When I attempt to access my web app http://server:port/context/index.xhtml it is hitting the FacesServlet correctly but then instantly the Request Dispatcher is redirecting to index.jsp???
I don't have any JSP specified ANYWHERE in my code, my app, my web.xml, and in fact I specified DEFAULT-SUFFIX to be .xhtml and that didn't help. All my web pages are .xhtml extension and FacesServlet is mapped correctly to *.xhtml.
I have tried adding XHTML as a mime type to WebSphere, disabling the Request Dispatcher, all to no avail. I have been able to get this running correctly on Tomcat 6-7, JBoss 6 and Glassfish 3 with no problems but for some reason WebSphere insists on a JSP file extension?
I appreciate any help you might have.
WAS7 sometimes does not undeploy the web applications properly. Clearing WAS_PROFILE_HOME/temp and WAS_PROFILE_HOME/wstemp may help.

JSF 2.0, RAD 8 & Websphere Application Server 7.0

I am trying to run a JSF 2.0 application with Mojarra 2.0 implementation. I need to change the Web Module class loading policy of the .war file to PARENT_LAST, so that WAS doesn't load the default configuration. I want the JSF 2.o implementation to be loaded from WEB-INF/lib folder. However RAD does not allow me to change the settings to PARENT_LAST in admin Console. ( It's disabled )
It works fine,when the class loader policy is set using shared libarary references and set at the server level. However I don't want that.
I would like this to be loaded at the "Web Module" level.
Can anyone help how to change to PARENT_LAST that using admin console?
Thanks!
I changed the deployment.xml file directly to include warClassLoaderPolicy="SINGLE" and changed the mode of the classloader element to "PARENT_LAST". It loaded the Mojarra JSF 2.0 implemention.

Weblogic 10 and Struts 2.x problem - Javassist

Please help with this issue, I'm going mad...
I'm trying to make a client-server web application using Weblogic 10 as an application server and IIS as a webserver (corporate constraints), with EJB 3 and Struts 2. I am however having strage problems which I cannot solve.
Using Struts 2.2 I get the following stack trace while starting the server:
<12-ott-2010 16.02.21 CEST> <Error> <HTTP> <BEA-101165> <Could not load user def
ined filter in web.xml: org.apache.struts2.dispatcher.FilterDispatcher.
java.lang.reflect.InvocationTargetException - Class: com.opensymphony.xwork2.inj
ect.ContainerImpl$MethodInjector
File: ContainerImpl.java
Method: inject
Line: 295 - com/opensymphony/xwork2/inject/ContainerImpl.java:295:-1
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.
java:190)
at weblogic.servlet.internal.FilterManager$FilterInitAction.run(FilterMa
nager.java:320)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
Truncated. see log file for complete stacktrace
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[...]
java.lang.IllegalArgumentException: Javassist library is missing in classpath! P
lease add missed dependency!
at ognl.OgnlRuntime.<clinit>(OgnlRuntime.java:165)
[...]
However, the Javassist package is clearly visible in the web classpath (/WEB-INF/lib direcotry) among all the other Struts-related libraries, I can also browse its packages and classes. I also put it in the CLASSPATH library and in Weblogic initializaion parameters but nothing works. I don't know what to think. Is this a Struts 2/Weblogic integration bug?
Even weirder is the fact that initially I managed to make Struts 2 work. Then for some reason (I don't really know what for) it stopped and I can't get rid of that error.
Thanks for your help.
Often solutions come when all hope is lost. Apparently all I had to do was moving all Struts libraries (including Javassist) to the /lib directory of the parent EAR project. This sounds weird to me, but it works and I'm sticking with the solution.
I'm not very familiar with Weblogic and Enterprise apps in general, so it didn't came to mind readily that the server treats the EAR as the base context and not the contained WAR.

Resources