CXF on Weblogic and Errors


We were getting weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler cannot be cast to org.apache.cxf.frontend.ClientProxy exception when deploying our CXF client on the WebLogic Server Version: 10.3.6.0.
Along with this I was seeing this error on my Weblogic logs.

WARNING: Registering oracle.j2ee.ws.wsdl.extensions.addressing.AddressingExtensionRegistry
 extension failed; java.lang.ClassNotFoundException: oracle.j2ee.ws.wsdl.extensions.addressing.AddressingExtensionRegistryweblogic.wsee.jaxws.spi.
WLSServiceDelegate addWsdlDefinitionFeature
SEVERE: Failed to create WsdlDefinitionFeature for wsdl location:

We tried different things but nothing fixed the issue.  Only one thing I was sure with this error that Weblogic server was trying to use it own implementation of the javax.xml.ws.spi. I tried the different class loader settings like giving preference to the war classes over the Weblogic system libraries and giving preference to explicitly to cxf libraries but nothing seems working.

<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

<container-descriptor>
<prefer-application-packages>
    <package-name>org.apache.cxf.binding.soap.saaj.*</package-name>
    <package-name>org.apache.cxf.endpoint.*</package-name>
    <package-name>org.apache.cxf.frontend.*</package-name>
    <package-name>org.apache.cxf.transport.http.*</package-name>
    <package-name>org.apache.cxf.interceptor.*</package-name>
    <package-name>org.apache.cxf.transports.http.configuration.*</package-name>
                        <package-name>com.sun.xml.messaging.saaj.*</package-name>
</prefer-application-packages>
 </container-descriptor>


snapshot of classloaders using Weblogic  Classloader Analysis Tool

Finally after looking into the javax.xml.ws.spi.Provider documentation and reading it algorithm I realized the way of fixing the issue.
The algorithm used to locate the provider subclass to use consists of the following steps:
  • If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then its first line, if present, is used as the UTF-8 encoded name of the implementation class.
  • If the $java.home/lib/jaxws.properties file exists and it is readable by the java.util.Properties.load(InputStream) method and it contains an entry whose key is javax.xml.ws.spi.Provider, then the value of that entry is used as the name of the implementation class.
  • If a system property with the name javax.xml.ws.spi.Provider is defined, then its value is used as the name of the implementation class.
  • Finally, a default implementation class name is used.

I have to force Weblogic to take the CXF javax.xml.ws.spi.Provider. Weblogic.xml has element prefer-application-resources which specify a list of resources that must always be loaded from the application, even if the resources are found in the system classloader. So once I made change to use the META-INF/services/javax.xml.ws.spi.Provider which is present inside my cxf-2.5.2.jar the error was gone and my CXF client starts working.


<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
<container-descriptor>
<prefer-application-resources> 
     <resource-name>META-INF/services/javax.xml.ws.spi.Provider</resource-name> 
   </prefer-application-resources> 
 </container-descriptor>
</weblogic-web-app>

Comments

  1. Very obscure problem and thanks for posting your solution. I tried adding the you suggested and it workd. FYI, this is on WebLogic 12c 12.1.1.0

    ReplyDelete
  2. Hi Ravi,

    we are using WLP 10.3.6 and recently upgraded to JDK1.7. After this change we started getting the above mentioned issue. However, on updating weblogic.xml with preferred application resource is not resolving the issue. The following is stack trace for it.

    WARNING: Registering oracle.j2ee.ws.wsdl.extensions.addressing.AddressingExtensionRegistry extension failed; java.lang.ClassNotFoundException: oracle.j2ee.ws.wsdl.extensions.addressing.AddressingExtensionRegistry
    Nov 25, 2015 10:28:27 AM weblogic.wsee.jaxws.spi.WLSProvider createServiceDelegate
    WARNING: Could not read WSDL Definition from URL wsdlDocumentLocation: 2 counts of InaccessibleWSDLException.

    Nov 25, 2015 10:28:32 AM weblogic.wsee.jaxws.framework.policy.advertisementimpl.AdvertisementHelperImpl registerExtension
    WARNING: Registering oracle.j2ee.ws.wsdl.extensions.addressing.AddressingExtensionRegistry extension failed; java.lang.ClassNotFoundException: oracle.j2ee.ws.wsdl.extensions.addressing.AddressingExtensionRegistry
    Nov 25, 2015 10:28:32 AM weblogic.wsee.jaxws.spi.WLSServiceDelegate addWsdlDefinitionFeature

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. I think this can solve my question. Thanks

    ReplyDelete

Post a Comment