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:
1st question: Are my observations correct?
2nd question: What can I do/try to resolve this?
Extra information:
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...
答案 0 :(得分:3)
好的,我解决了这个问题。我找到了冲突的依赖项;
使用
WebLogic的web应用程序/容器描述符
对我不起作用:
prefer-web-inf-classes = true
已经设置并将其更改为更喜欢应用程序包只会导致更多麻烦,因为项目已经依赖于prefer类配置。
我使用findjar来查找哪个jar是我的QName resides并将这些jar放在我的记忆中。
然后使用
mvn依赖:树
我得到了项目的所有依赖项和子项依赖项(不会发布它,因为POM很大)。
我注意到他们的名字中有两个带有'stax'的依赖项。一个'官方'stax jar(xmlbeans的子依赖)和一个来自genronimo(axiom的sub依赖)。所以我做了一些研究,发现geronimo stax是对原始stax jar的实现/改编,因此都包含QName。 我从依赖列表中删除了原始的stax:
<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>
希望有所帮助:)
答案 1 :(得分:1)
您可以通过将prefer-web-inf-classes添加到WAR文件中的weblogic.xml来告诉WebLogic使用您的应用程序类。
<weblogic-web-app>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
答案 2 :(得分:1)
WebLogic还允许您指定应用程序与WLS类路径中使用的程序包:
<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
表示应用程序中打包的内容始终优先于WebLogic的设置,这可能是也可能不是一件好事。