Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

java - Guava and Weblogic:ClassNotFoundException

I'm trying to work on a web application that deploys to Weblogic 10.3.5. One of the maven dependencies is Guava.

Unfortunately, upon attempting to publish the project, weblogic throws this exception:

java.lang.ClassNotFoundException: com.google.common.eventbus.EventBus
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)

The rest of my maven dependencies SEEM to be working, but I'm unsure what the problem is.

Can anyone assist in troubleshooting? Environment is Eclipse with M2E plugin, Weblogic Server is integrated into Eclipse.

Update: Guava entry in pom.xml:

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>11.0.2</version>
    </dependency>

I included another library (commons-lang) and it worked fine.

Update 2: This may be a classloader issue. I got a clue from this blog: http://blog.eisele.net/2011/12/running-richfaces-410final-on-weblogic.html. It seems WLS uses some google-commons library.

I'm trying to force it to use my version by making changes in the weblogic.xml file, but it doesn't seem to be working.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  • Yes it's classloader issue (application vs. WebLogic classloading)
  • guava libraries and com.google.common contains same classes
  • WebLogic has com.google.common_1.0.0.0_0-6.jar or com.google.common_1.1.0.0_0-6.jar in it's classpath, in modules directory. (depending on WebLogic version, but the jar content is same, only META-INFMANIFEST.MF is different)
  • You cannot find this library in WebLogic Classloader Analysis Tool (CAT). I'm not sure why is that....
  • Why not using WebLogic built in feature with help of FilteringClassLoaders - prefer-application-packages ?

you need to add something like this to your weblogic.xml or weblogic-application.xml if you are in EAR application

<wls:container-descriptor>
    <wls:prefer-application-packages>
            <wls:package-name>com.google.common.*</wls:package-name>
    </wls:prefer-application-packages>
</wls:container-descriptor>

Then redeploy the application.

It works for us.

  • pros: no need to replace & rename magic with com.google.common*.jar files... that's a way to suicide...

Hope it helps.

For more info, see the link:
https://www.rational-pi.be/2013/03/guava-and-weblogic12c/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...