How do I resolve this Weblogic intermittent java.lang.LinkageError? What are the steps to understanding what it means and fix it?

不问归期 提交于 2019-12-08 06:56:52

问题


I have an intermittent linkage error thrown: (That's basically all the information I have)

java.lang.LinkageError loader constraint violation: 
  when resolving field 'service' of the class loader instance of 
  java/net/FactoryURLClassLoader) of the referring class 
  org/apache/axis/client/Stub, and the class loader (instance of
  weblogic/utils/classloaders/ChangeAwareClassLoader) 
  for the field's resolved type, java/xml/rpc/Service, 
  have different class objects for that type

Or in a more readable way

  • Exception: java.lang.LinkageError

    • field: service
    • CL instance: java.net.FactoryURLClassLoader
    • reffering class: org.apache.axis.client.Stub
    • 2nd CL instance: weblogic.utils.classloaders.ChangeAwareClassLoader
    • field's resolve type: java.xml.rpc.Service

Does this mean that I have 2 versions of java.xml.rpc.Service loaded? Is that so? How can that happen? what is the way to resolve it?


回答1:


Does this mean that I have 2 versions of java.xml.rpc.Service loaded? Is that so?

Yes.

How can that happen?

It happens when you have two classloaders both loading the same class. In your case, the classloaders are instances of different ClassLoader classes:

    java.net.FactoryURLClassLoader

and

    weblogic.utils.classloaders.ChangeAwareClassLoader

what is the way to resolve it?

I'm not a Weblogic user, but the theoretical solution is to put the JAR file containing the classes in question into the classpath of an common ancestor classloader of the two above.




回答2:


The solution was eventually to update the weblogic-application.xml file of the deployed app

The application used an old jaxrpc-api.jar that we could not remove for various reason,

The solution we used to prefer the internal jar was this (Is there a better way?)

<wls:prefer-application-packages>
  ...
  <wls:package-name>java.xml.rpc.*</wls:package-name>
</wls:prefer-application-packages>


来源:https://stackoverflow.com/questions/9997212/how-do-i-resolve-this-weblogic-intermittent-java-lang-linkageerror-what-are-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!