Guava/Logback and Weblogic12c

Using Google’s Guava libraries with Oracle’s Weblogic 12c is not a no-brainer. This is the result of Weblogic using a very old version of the Google Collections library, which is the predecessor of Guava, provides the same classes and more, but also uses the same package name – “…/weblogic12/modules/”.

Of course there is a very simple “solution” that you can find on many places on the web (e.g. here and here): replace the Weblogic file with a renamed updated version of the library.

This solution is obviously suicide for any stable production environment, despite of the fact that this seem to work at first sight. It’s like installing a Nitro injection in your car with the risk that the motor explodes one moment or another.

However, there is a clean solution to the problem. In the “weblogic.xml” file, you can tell Weblogic to prefer the libraries provided in your classpath to the ones provided in  Weblogic’s classpath. This applies to your application only. The same works well, by the way, if you want to use SLF4J and Logback instead of Weblogic’s Log4J.

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns .../.. .web-app/1.3/weblogic-web-app.xsd">
               <!-- Priority is given to SLF4J / Logback JARs embedded with the WAR instead of Weblogic's log4j -->

The same should be possible using the <prefer-web-inf-classes> tag instead, but I never tried this possibility.

1 thought on “Guava/Logback and Weblogic12c

  1. If I’m specifying
    I get another error when I try to start the app in weblogic:

    java.lang.NoSuchMethodException:, java.lang.ref.ReferenceQueue, java.lang.ref.PhantomReference)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.