3

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.

Jason
  • 3,943
  • 12
  • 64
  • 104
  • What does the dependency in your `pom.xml` look like? – Mark Peters Mar 13 '12 at 16:41
  • 1. Could tell the what version of guava is resolved (look in m2e plugin) 2. Are you sure `guava.jar` is included in application deployed at WebLogic? – korifey Mar 13 '12 at 16:52
  • Under properties->Java Build Path, Libraries Tab, the listing is for guava-11.0.2.jar. I'm honestly not sure where to look for the actual weblogic deployment, as I'm not sure if it is pointing at the maven target directory. – Jason Mar 13 '12 at 16:59

2 Answers2

13
  • 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-INF\MANIFEST.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/

Casey
  • 1,402
  • 1
  • 19
  • 23
  • Worked for me as well, but my weblogic.xml does not use the wls: prefix... i removed it and it worked fine. – Elye M. Oct 29 '13 at 19:29
  • 2
    I am having a similar problem and would like to make this work. Problem is that I don't know which xml to add this to. I'm using weblogic 12c I tried adding this to the base xml's, the temp domain xml, as well as creating a new xml in my project's WEB-INF. The first 2 didn't work. The last one the dtd enforcement indicated that prefer-application-packages was invalid. – user3056052 Mar 19 '14 at 13:48
  • For WAR: WEB-INF/weblogic.xml For an EAR application META-INF/weblogic-application.xml Check your xml structure or dtd validator. Oracle documentation has that element: https://docs.oracle.com/middleware/1221/wls/WBAPP/weblogic_xml.htm#WBAPP660 Xsd schema has it too: http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd --> this group: --> xs:include'd from schemaLocation = "http://xmlns.oracle.com/weblogic/weblogic-javaee/1.8/weblogic-javaee.xsd" – Casey Apr 11 '17 at 08:02
3

Go to your weblogic folder, weblogic-home >modules and if there is a com.google.common....jar file, just delete it and replace it with a guava.jar file, and you have to rename the guava file with the old com.google.common......jar name (cuz weblogic is looking for this name, but its conflicting with your guava file).

i had the same problem here

Community
  • 1
  • 1
Elye M.
  • 2,667
  • 4
  • 30
  • 43
  • We are having the same issue with the spring.jar provided by WLS,but I've been trying to find a different solution. Deleting jars provided by the server strikes me as performing surgery with a chainsaw. – Jason Nov 26 '12 at 13:00
  • So don't delete it at all, first cut and paste it somewhere else, and do like i mentioned, and if its working be happy! if not just paste it back to the same place it was before. – Elye M. Dec 13 '12 at 18:39