4

I am working on a big application and I just added a new web service generated by eclipse with the help of axis. The application runs fine in my development environment (where the application is hosted by jetty) but now I am having trouble when running my application in weblogic (where the application needs to be deployed). The error I am getting is:

java.lang.LinkageError: loader constraint violation in interface
itable initialization: when resolving method
"org.apache.axis.client.Service.getServiceName()Ljavax/xml/namespace/QName;"
the class loader (instance of
weblogic/utils/classloaders/ChangeAwareClassLoader) of the current
class, org/apache/axis/client/Service, and the class loader (instance
of sun/misc/Launcher$AppClassLoader) for interface
javax/xml/rpc/Service have different Class objects for the type
getServiceName used in the signature

This issue is delaying development for days already. As I understand from looking on the web:

  • My Axis dependency contains the class: org.apache.axis.client.Service which follows the javax.xml.rpc.Service interface.
  • My Weblogic provided the interface: javax.xml.rpc.Service
  • Since they are in a different path (application and weblogic) they are loaded by different classloaders

1st question: Are my observations correct?

2nd question: What can I do/try to resolve this?

Extra information:

  • Using Maven.
  • To make sure all dependencies loaded by Weblogic are also available in our development environment we added the wlsfullclient.jar as a dependency (only in our dev env).
  • Since our weblogic server is used by a lot of projects I can not just add the Axis jar to the weblogic path.
  • I found a similar issue already on Stack: How to deal with LinkageErrors in Java?.
    • Their solution is not clear for me though I am interested in Alex Miller's reply, specifically: "That may mean removing it from the classpath and loading as a plugin".
      • Does this apply on the application side or is this the web logic side?
  • If more information is required I will gladly provide it.

EDIT: I have a weblogic.xml in my project with the following content:

<?xml version='1.0' encoding='UTF-8'?>
  <weblogic-web-app >
    <container-descriptor>
      <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>
  <context-root>auditgui</context-root>
</weblogic-web-app>

The structure of my WAR file is as follows:

file.war
    |--crossdomain.xml
    |--robots.txt
    |--META-INF
    |   \--MANIFEST.MF
    |--WEB-INF
    |   |--classes
    |   |   |--com
    |   |   |   \--...
    |   |   |--spring
    |   |   |   |--main-context.xml
    |   |   |   \--security-context.xml
    |   |   \--environment-beans.xml
    |   |--lib
    |   |   \--multiplejars.jar
    |   |--spring
    |   |   |--raw-servlet-context.xml
    |   |   |--root-context.xml
    |   |   \--servlet-context.xml
    |   |--web.xml
    |   \--weblogic.xml
    |--css
    |   \--multipleCSSFiles.css
    |--js
    |   \--multipleJSFiles.js...
    |--img
    |   \--muultipleImages.png...
    \--multipleHTMLFiles.html...
Community
  • 1
  • 1
J Bre
  • 107
  • 1
  • 10

3 Answers3

4

Ok I solved the issue. I found the conflicting dependencies;

Recap:

Using the

weblogic-web-app/container-descriptor

did not work for me:

prefer-web-inf-classes = true

was already set and changing it to prefer application packages only caused more trouble since the project already depended on the prefer classes configuration.

Solution:

I used findjar for looking up in which jar's my QName resides and put these jar's in my memory.

Then by using

mvn dependency:tree

I got all the dependencies and sub dependencies of my project (wont post it because the POM is BIG).

I noticed that there were two dependencies with 'stax' in their name. One 'official' stax jar (sub dependency of xmlbeans) and one from genronimo (sub dependency of axiom). So I did some research and found out that the geronimo stax is an implementation/adaption on the original stax jar and therefore both contain QName. I removed the original stax from my dependency list:

    <dependency>
        <groupId>org.apache.xmlbeans</groupId>
        <artifactId>xmlbeans</artifactId>
        <version>2.5.0</version>
        <!-- Excluding XMLBean's STAX because we want to use axiom/geronimo-stax -->
        <exclusions>
            <exclusion>
                <groupId>stax</groupId>
                <artifactId>stax-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Hope it helps :)

J Bre
  • 107
  • 1
  • 10
1

You can tell WebLogic to use your application classes by adding prefer-web-inf-classes to the weblogic.xml in your WAR file.

<weblogic-web-app>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
Brian Ochs
  • 1,099
  • 1
  • 10
  • 21
  • Thank you for your reply Brian. The thing is that I already have this in my weblogic.xml. Why is this not working then? (I've added the contents of the weblogic.xml and my file structure) – J Bre Oct 30 '15 at 12:43
  • Have you tried using the WebLogic Class Analysis Tool to see where exactly WebLogic is picking up this class? – Brian Ochs Oct 30 '15 at 13:04
  • Sadly I have no access to the CAT tool at the moment, I am in contact with the responsible team in our project as we speak, though I fear that they wont give access. Is there an alternative way of doing class(loader) analysis? – J Bre Oct 30 '15 at 14:46
1

WebLogic will also let you specify which packages to use from your app vs. from the WLS classpath:

<weblogic-web-app>
  <container-descriptor>
    <prefer-application-packages>
      <package-name>org.apache.commons.*</package-name>
      <package-name>org.apache.log4j.*</package-name>
      <package-name>org.slf4j.*</package-name>
    </prefer-application-packages>
  </container-descriptor>
</weblogic-web-app>

prefer-web-inf-classes means that what's packaged in the app always takes precedence over WebLogic's settings, which may or may not be a good thing.

user944849
  • 14,524
  • 2
  • 61
  • 83
  • Thank you for your reply. I tried this but this produced an error while deploying from our Bamboo server: error 30-Oct-2015 14:31:04 java.lang.NoSuchMethodError: org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues; error 30-Oct-2015 14:31:04 at org.springframework.web.servlet.config.AnnotationDrivenBeanDefinitionParser.parse(AnnotationDrivenBeanDefinitionParser.java:102) – J Bre Oct 30 '15 at 13:44
  • I ran it with the following weblogic.xml: org.apache.axis.* javax.xml.rpc.* – J Bre Oct 30 '15 at 13:46
  • What version of WebLogic? We use similar configuration with 10.3.6 and 12.1.x. It would also be good to try deploying without Bamboo/CI server. The fewer tools in the mix when trying to troubleshoot, the better. – user944849 Nov 05 '15 at 13:55