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...

3 Answers 3

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 :)

Sign up to request clarification or add additional context in comments.

Comments

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>

3 Comments

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)
Have you tried using the WebLogic Class Analysis Tool to see where exactly WebLogic is picking up this class?
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?
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.

3 Comments

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)
I ran it with the following weblogic.xml: <prefer-application-packages> <package-name>org.apache.axis.*</package-name> <package-name>javax.xml.rpc.*</package-name> </prefer-application-packages>
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.