IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 14 replies
  • Latest Post - ‏2013-04-02T04:19:38Z by SystemAdmin
SystemAdmin
SystemAdmin
6420 Posts

Pinned topic Both MyFaces and the RI are on your classpath

‏2007-08-06T13:09:39Z |
We are using Websphere 6.1 and we want to use MyFaces instead of the Sun RI. We have followed the instructions at http://wiki.apache.org/myfaces/Websphere_Installation, including setting the module classloader policy to application first, but still we get the following ERROR message from (apparently) the web container. Does anyone know how we can completely remove Sun RI artifacts from the classpath?

8/6/07 9:02:54:054 EDT 0000001e SystemOut O 2007-08-06 09:02:54,038 ERROR WebContainer : 0 (MyfacesConfig.java:191, getCurrentInstance) - Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.
Updated on 2013-04-02T04:19:38Z at 2013-04-02T04:19:38Z by SystemAdmin
  • kennas
    kennas
    19 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2007-08-06T15:09:32Z  
    Are you only getting this error? or does your application actually not run after this? The classloading should work since you switched to PARENT_LAST, even though both impls are on the classpath, MyFaces will always be loaded first since it is first on the classpath.

    Please post any other errors/exceptions you are seeing so we can help further.
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2007-08-06T18:47:08Z  
    We no longer get the 'Both MyFaces and the RI are on your classpath' message. But, after setting the module classloader policy to application first, we get the following exception on server startup:

    8/6/07 14:38:39:328 EDT 0000001e SystemErr R java.lang.IllegalArgumentException: Class org.springframework.web.jsf.DelegatingVariableResolver is no javax.faces.el.VariableResolver

    This is an already developed and running application. We are trying to get it to run on WebSphere as well. We have kept all of the libraries in the root of the EAR, but because WebSphere ties Sun's JSF RI into the web container, we have had to move libraries back into the WEB-INF lib folder. I think we have to figure out the right combination of our 41 library jars to keep in the EAR and which to keep in the WAR.
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2007-08-07T14:54:26Z  
    • kennas
    • ‏2007-08-06T15:09:32Z
    Are you only getting this error? or does your application actually not run after this? The classloading should work since you switched to PARENT_LAST, even though both impls are on the classpath, MyFaces will always be loaded first since it is first on the classpath.

    Please post any other errors/exceptions you are seeing so we can help further.
    We are getting this message on the console:

    Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.

    We are using only the MyFaces implementation in our app, which has been running for several months on Tomcat without incident.

    This is our setup:
    All of the library jars are in the root of the EAR. A jar that includes the business tier classes (mostly Spring and Hibernate) is also in the root of the EAR. The 'web tier' classes are in WEB-INF/classes. We have no jars in WEB-INF/lib. Instead, using ant, we put the jars that the web tier classes refer to on the WAR's manifest class path, like this:

    <manifest>
    <attribute name="Class-Path" value=" myfaces-api-1.1.5.jar myfaces-impl- 1.1.5.jar richfaces-3.0.1.jar tomahawk-1.1.5.jar
    </manifest>

    We also set the the WAR classloader policy using Manage Modules to 'Classes loaded woth application class loader first'.

    We believe that this is a reasonable setup. We do not want in any way for the Sun's RI to creep into the picture, since we did not develop the app using that particular implementation.

    The application is breaking on one of our pages and is reporting the following exception: java.lang.IllegalStateException: Duplicate component ID 'lookUpCustomer:_id8' found in view.

    The stack trace that follows shows that a SUN RI class is being called:
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(

    We understand the duplicate id issues, which the SUN RI does not handle well. That is one of the reasons we went with MyFaces. Again, this app and this particular page runs fine on Tomcat, where there is no unwarranted interference from the SUN JSF implementation.

    Is there any way to keep the SUN RI out of the picture in Websphere? We have tried everything we can think of. Again, we believe that it is a reasonable approach to just want to use the JSF jars that we have bundled in our EAR.
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2007-08-07T14:56:50Z  
    We no longer get the 'Both MyFaces and the RI are on your classpath' message. But, after setting the module classloader policy to application first, we get the following exception on server startup:

    8/6/07 14:38:39:328 EDT 0000001e SystemErr R java.lang.IllegalArgumentException: Class org.springframework.web.jsf.DelegatingVariableResolver is no javax.faces.el.VariableResolver

    This is an already developed and running application. We are trying to get it to run on WebSphere as well. We have kept all of the libraries in the root of the EAR, but because WebSphere ties Sun's JSF RI into the web container, we have had to move libraries back into the WEB-INF lib folder. I think we have to figure out the right combination of our 41 library jars to keep in the EAR and which to keep in the WAR.
    We are getting this message on the console:

    Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.

    We are using only the MyFaces implementation in our app, which has been running for several months on Tomcat without incident.

    This is our setup:
    All of the library jars are in the root of the EAR. A jar that includes the business tier classes (mostly Spring and Hibernate) is also in the root of the EAR. The 'web tier' classes are in WEB-INF/classes. We have no jars in WEB-INF/lib. Instead, using ant, we put the jars that the web tier classes refer to on the WAR's manifest class path, like this:

    <manifest>
    <attribute name="Class-Path" value=" myfaces-api-1.1.5.jar myfaces-impl- 1.1.5.jar richfaces-3.0.1.jar tomahawk-1.1.5.jar
    </manifest>

    We also set the the WAR classloader policy using Manage Modules to 'Classes loaded woth application class loader first'.

    We believe that this is a reasonable setup. We do not want in any way for the Sun's RI to creep into the picture, since we did not develop the app using that particular implementation.

    The application is breaking on one of our pages and is reporting the following exception: java.lang.IllegalStateException: Duplicate component ID 'lookUpCustomer:_id8' found in view.

    The stack trace that follows shows that a SUN RI class is being called:
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(

    We understand the duplicate id issues, which the SUN RI does not handle well. That is one of the reasons we went with MyFaces. Again, this app and this particular page runs fine on Tomcat, where there is no unwarranted interference from the SUN JSF implementation.

    Is there any way to keep the SUN RI out of the picture in Websphere? We have tried everything we can think of. Again, we believe that it is a reasonable approach to just want to use the JSF jars that we have bundled in our EAR. ">
  • bergmark
    bergmark
    36 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2007-08-07T15:30:45Z  
    We are getting this message on the console:

    Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.

    We are using only the MyFaces implementation in our app, which has been running for several months on Tomcat without incident.

    This is our setup:
    All of the library jars are in the root of the EAR. A jar that includes the business tier classes (mostly Spring and Hibernate) is also in the root of the EAR. The 'web tier' classes are in WEB-INF/classes. We have no jars in WEB-INF/lib. Instead, using ant, we put the jars that the web tier classes refer to on the WAR's manifest class path, like this:

    <manifest>
    <attribute name="Class-Path" value=" myfaces-api-1.1.5.jar myfaces-impl- 1.1.5.jar richfaces-3.0.1.jar tomahawk-1.1.5.jar
    </manifest>

    We also set the the WAR classloader policy using Manage Modules to 'Classes loaded woth application class loader first'.

    We believe that this is a reasonable setup. We do not want in any way for the Sun's RI to creep into the picture, since we did not develop the app using that particular implementation.

    The application is breaking on one of our pages and is reporting the following exception: java.lang.IllegalStateException: Duplicate component ID 'lookUpCustomer:_id8' found in view.

    The stack trace that follows shows that a SUN RI class is being called:
    at com.sun.faces.application.StateManagerImpl.removeTransientChildrenAndFacets(

    We understand the duplicate id issues, which the SUN RI does not handle well. That is one of the reasons we went with MyFaces. Again, this app and this particular page runs fine on Tomcat, where there is no unwarranted interference from the SUN JSF implementation.

    Is there any way to keep the SUN RI out of the picture in Websphere? We have tried everything we can think of. Again, we believe that it is a reasonable approach to just want to use the JSF jars that we have bundled in our EAR. ">
    I believe one part of the problem may be that the library classes are still being loaded by the ear level application class loader and not the war classloader, and as such your "Classes loaded with application class loader first" at the war level isn't helping. You could try moving the faces related jars into the WEB-INF/lib.

    Another option would be setting the ear level application level class loader to parent_last, but then you risk other jars taking precedence over Websphere classes.
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2007-08-07T16:30:54Z  
    • bergmark
    • ‏2007-08-07T15:30:45Z
    I believe one part of the problem may be that the library classes are still being loaded by the ear level application class loader and not the war classloader, and as such your "Classes loaded with application class loader first" at the war level isn't helping. You could try moving the faces related jars into the WEB-INF/lib.

    Another option would be setting the ear level application level class loader to parent_last, but then you risk other jars taking precedence over Websphere classes.
    Thanks. We tried that as well. No luck. Does anyone out there know how to keep the Sun JSF RI off of the classpath, or if it is even possible in WebSphere 6.1?

    Are we wrong in believing that we should be able to package a different implementation of JSF and have it run without incident in WebSphere, as long as we adhere to J2EE standards in managing the classpath in the manifest, in packaging the application in EAR and WAR files, etc?
  • bergmark
    bergmark
    36 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2007-08-07T20:10:59Z  
    Thanks. We tried that as well. No luck. Does anyone out there know how to keep the Sun JSF RI off of the classpath, or if it is even possible in WebSphere 6.1?

    Are we wrong in believing that we should be able to package a different implementation of JSF and have it run without incident in WebSphere, as long as we adhere to J2EE standards in managing the classpath in the manifest, in packaging the application in EAR and WAR files, etc?
    It is not possible to remove WebSphere's JSF implementation completely from the classpath.

    You should, however, be able to set the classloader order so that the implementation bundled with the application is picked up instead of WebSphere's at run time.

    Do you have any more details on what errors you were getting when the jsf jars were in the WEB-INF/lib of the WAR?
  • SystemAdmin
    SystemAdmin
    6420 Posts

    more details on what errors you were getting when the jsf jars were in the WEB-INF/lib of the WAR

    ‏2007-08-08T17:24:20Z  
    • bergmark
    • ‏2007-08-07T20:10:59Z
    It is not possible to remove WebSphere's JSF implementation completely from the classpath.

    You should, however, be able to set the classloader order so that the implementation bundled with the application is picked up instead of WebSphere's at run time.

    Do you have any more details on what errors you were getting when the jsf jars were in the WEB-INF/lib of the WAR?
    Here is the stack trace:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource http://applicationContext.xml: Invocation of init method failed; nested exception is org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method http://public abstract java.sql.Connection javax.sql.DataSource.getConnection() throws java.sql.SQLException on target com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@e91e60c1; nested exception is java.lang.IllegalArgumentException

    The issue is Spring. When we put the JSF jars in the web-inf/lib folder, we can't configure Spring. We have even tried putting the Spring jar in the WEB-INF lib folder as well, but we get the same error.

    When we put all of the jars in the root of the EAR, and set the classpath in the manifest that ant creates, everything is initialized correctly, and Spring and Hibernate work as planned (i.e Spring asks Hibernate to get data from the database and it does), but some of the web pages break because of the interference from the Sun RI.
  • bergmark
    bergmark
    36 Posts

    Re: more details on what errors you were getting when the jsf jars were in the WEB-INF/lib of the WA

    ‏2007-08-08T18:22:33Z  
    Here is the stack trace:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource http://applicationContext.xml: Invocation of init method failed; nested exception is org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method http://public abstract java.sql.Connection javax.sql.DataSource.getConnection() throws java.sql.SQLException on target com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@e91e60c1; nested exception is java.lang.IllegalArgumentException

    The issue is Spring. When we put the JSF jars in the web-inf/lib folder, we can't configure Spring. We have even tried putting the Spring jar in the WEB-INF lib folder as well, but we get the same error.

    When we put all of the jars in the root of the EAR, and set the classpath in the manifest that ant creates, everything is initialized correctly, and Spring and Hibernate work as planned (i.e Spring asks Hibernate to get data from the database and it does), but some of the web pages break because of the interference from the Sun RI.
    > Here is the stack trace:
    >
    > org.springframework.beans.factory.BeanCreationExceptio
    > n: Error creating bean with name 'sessionFactory'
    > defined in class path resource
    > http://applicationContext.xml: Invocation of init method
    > failed; nested exception is
    > org.springframework.aop.AopInvocationException: AOP
    > configuration seems to be invalid: tried calling
    > method [public abstract java.sql.Connection
    > javax.sql.DataSource.getConnection() throws
    > java.sql.SQLException] on target
    > com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@e91e60c1;
    > nested exception is
    > java.lang.IllegalArgumentException
    >
    > The issue is Spring. When we put the JSF jars in the
    > web-inf/lib folder, we can't configure Spring. We
    > have even tried putting the Spring jar in the WEB-INF
    > lib folder as well, but we get the same error.
    >

    I'm afraid I don't know enough about Spring to understand why this might be failing. On the surface it doesn't appear JSF related.

    > When we put all of the jars in the root of the EAR,
    > and set the classpath in the manifest that ant
    > creates, everything is initialized correctly, and
    > Spring and Hibernate work as planned (i.e Spring asks
    > Hibernate to get data from the database and it does),
    > but some of the web pages break because of the
    > interference from the Sun RI.
    >

    If you put the jars in the root of the EAR and reference them in the manifest then a couple of things are probably happening:

    1) The ear level application class loader is used, which to my understanding is not currently set to PARENT_LAST. That means it will load the jsf classes from WebSphere first.

    2) The tlds from within the myfaces jar are also probably not being loaded.
  • RHAT
    RHAT
    1 Post

    Re: Both MyFaces and the RI are on your classpath

    ‏2007-09-15T17:34:36Z  
    May I ask why you chose to switch to myfaces?
    I have not the best experience with myfaces, especially the tomahawk components
    are of low quality.
    I really consider RI + Woodstock for the next project.
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2008-01-04T19:56:13Z  
    • RHAT
    • ‏2007-09-15T17:34:36Z
    May I ask why you chose to switch to myfaces?
    I have not the best experience with myfaces, especially the tomahawk components
    are of low quality.
    I really consider RI + Woodstock for the next project.
    Looks like there is no solution available for this. Please see
    http://www-1.ibm.com/support/docview.wss?uid=swg21291065
  • frabber
    frabber
    2 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2008-01-14T09:06:56Z  
    Looks like there is no solution available for this. Please see
    http://www-1.ibm.com/support/docview.wss?uid=swg21291065
    Try using the modular spring jars. Move the spring-web.jar (which references delegating-variable-resolver) into the web module web-inf lib . Al other spring module jars can go into the upper ear project.
    This should solve your spring problem in this context.

    Faizal Abdoelrahman
  • PrabuMurugaiyan
    PrabuMurugaiyan
    1 Post

    Re: Both MyFaces and the RI are on your classpath

    ‏2012-06-29T08:29:31Z  
    • kennas
    • ‏2007-08-06T15:09:32Z
    Are you only getting this error? or does your application actually not run after this? The classloading should work since you switched to PARENT_LAST, even though both impls are on the classpath, MyFaces will always be loaded first since it is first on the classpath.

    Please post any other errors/exceptions you are seeing so we can help further.
    hi kennas,

    thanks for your post. i resolved the issue with my deployment by fixing this. thanks

    prabu
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: Both MyFaces and the RI are on your classpath

    ‏2013-04-02T04:19:38Z  
    We experienced the same issue with Webpshere Application Server 8. After applying the fixpack 8.0.0.3, the issue was resolved.

    Mustansar