Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weblogic server guava NoSuchMethodError

I'm trying to deploy a web project with a war file on the weblogic server. But I'm getting an error like above,

java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
    at com.google.common.eventbus.EventBus.<init>(EventBus.java:138)

I tried lastest and oldest versions of guava. In the oldest versions I got eventbus error (no defined this method in the old versions). In the newest versions I got the same error again.

How can I solve this problem?

EDIT: It runs clearly in my editor (IntelliJ), when I try to run it on a weblogic server I get this error in deployment.

UPDATE:

I just added a weblogic.xml file like above in my WEB-INF path. No need any other configurasyon. The problem resolved for me thanks to @luc14n0

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">

<container-descriptor>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

</weblogic-web-app>
like image 769
stephan Avatar asked Oct 17 '25 15:10

stephan


1 Answers

Weblogic 12c (12.1.3) ships with its own Guava dependency at Oracle/Middleware/Oracle_Home/wlserver/modules/com.google.common_1.2.0.0_11-0-2.jar

By telling WebLogic you prefer to use your own version, you avoid the conflict where it loads the wrong library.

In case of an EAR, add the following to application.xml:

<prefer-application-packages>
  <package-name>com.google.common.*</package-name>
</prefer-application-packages>

In case of a WAR, add the following to weblogic.xml:

<container-descriptor>
  <prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
like image 99
Luciano van der Veekens Avatar answered Oct 19 '25 05:10

Luciano van der Veekens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!