{ Think. Ask Why. Do it. }

Using Guava in Weblogic and NoSuchMethodError

Recently I was working on a prototype, servlet based web application, using Google Guava cache library. And used weblogic 12c to host and test the application. During the application context initialization, it stoped and displayed following error.

Caused by: java.lang.NoSuchMethodError:

Why now? It ran without error in JBoss 7. Did I accidently changed any code, libraries, or maven build. So I checked the code again and I couldn't find any issues. Why it was failing? after some googling I figured that weblogic was loading a different version of the same class. To figure which library/class was loaded, I used below code:

//And it printed different library name which was part of weblogic feature jar file.

Ok, so even when I packed the latest library in war(lib folder), weblogic was loading its own class since it was part of the system library.
How to override it for my application? After reading the documentation about the class loading order of weblogic, I created the weblogic.xml to use the latest package as shown below:

<?xml version="1.0" encoding="UTF-8"?>




And updated the maven to include the weblogic.xml in the build and deployed again.
Yes, it ran without error by loading the latest library from the webapp.

Since the weblogic threw the error I was able to find that it was loading an old class instead of packaged jar class. What happens when it loads an old class which doesn't throw error? it becomes a serious issue by executing old logic.

By @Senthadev