Search code examples
javawebsphereclassloadercxf

CXF on WebSphere 6.1 Class Loading Problem


I have a project with the following configuration:

  • WebSphere Application Server 6.1.0.19
  • wsdl4j-1.6.2.jar at the $WAS_ROOT/java/jre/lib/ext directory, (to overwrite wsdl4j-1.6.1 included in WAS 6.1).
  • cxf-2.4.0.jar (and others dependencies) at the $WAS_ROOT/lib/ext directory.
  • An EAR 'X' with a Web Module 'Y'.
  • The Web Module 'Y' has a JAR Module 'Z' (at the WEB-INF/lib directory).
  • 'Z' has a set of classes that implement a SOAP Web Service generated using CXF's wsdl2java.
  • 'Y' has a business class (at the WEB-INF/classes directory) that calls the SOAP Web Service Client at 'Z'.

This configuration works well at my development enviroment (Rational Application Developer with a WebSphere AS 6.1 runtime). But at the QA enviroment, I had the following exception, (please pay attention at bolds in the stack trace):

org.apache.cxf.bus.extension.ExtensionException
at org.apache.cxf.bus.extension.Extension.loadInterface(Extension.java:134)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.loadAndRegister(ExtensionManagerImpl.java:160)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.getBeansOfType(ExtensionManagerImpl.java:256)
at org.apache.cxf.bus.CXFBusImpl.getExtension(CXFBusImpl.java:99)
at org.apache.cxf.endpoint.ClientImpl.notifyLifecycleManager(ClientImpl.java:186)
at org.apache.cxf.endpoint.ClientImpl.(ClientImpl.java:117)
at org.apache.cxf.frontend.ClientFactoryBean.createClient(ClientFactoryBean.java:104)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:92)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:152)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:464)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:331)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:318)
at javax.xml.ws.Service.getPort(Service.java:46)
at web.service.client.implementation.at.z.module.method(Unknown Source)
at business.class.at.y.web.module.method(AvisoCobroDAO.java:86)
... 32 more
Caused by: java.lang.ClassNotFoundException: org.apache.cxf.endpoint.ClientLifeCycleManager
at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java:472)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:373)

at java.lang.ClassLoader.loadClass(ClassLoader.java:561)
at org.apache.cxf.bus.extension.Extension.loadInterface(Extension.java:132)
... 51 more

Seems like the CompoundClassLoader (which works at application level) is trying to load a CXF's class which exists at the server runtime level.

I hope somebody help me with this issue. I'll be very very grateful.


Solution

  • Placing Jars in the WAS_HOME/lib/ext should be your last resort.

    Always try the PARENT_LAST classloader mode and have your classes/jars picked up first.

    This would avoid a number of problems for you.

    The App Server start up would use this directory extensively and if there are clashes it might not even start up.

    THe best way to troubleshoot is to turn on classloading and look at the native_stdout/stderr file and see who is loading the class(es) that is in question.

    Bkail,

    Did you mean to say things differently? This path is high up the class loader chain so it would be checked earlier (with the default PARENT_FIRST) class loading policy.

    This would be in the second rung (after the BOOT CLassloader of the JDK) and it's extensions.

    HTH

    Manglu