问题
I am getting the following error while deploying in my EAR. The exception is coming during Elastic search connection. In my EAR I have using guava version 18. Which is the recommended version for ES 2.0+ ( I am using ES 2.3.3)
weblogic.application.ModuleException: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
.....
Caused By: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at org.elasticsearch.threadpool.ThreadPool.<clinit>(ThreadPool.java:190)
at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:131)
at com.ventyx.servicesuite.dispatcher.ESClientMgr.connect(ESClientMgr.java:80)
....
In most of the search its mentioned that its because guava jars conflict.
java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor
So I have added -verbose:class as Java option while running my weblogic to see if old version of guava is loaded
But to my surprise it did not find any guava jar getting loaded. But I suspect that weblogic.server.merged.jar is have google libraries prepackaged in it.
So my question is Is there any way we could tell the container to use the jar files from the application rather than weblogic's ?
回答1:
I could resolve this problem by adding a weblogic-application.xml with prefer-application-packages to my EAR.
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.0/weblogic-application.xsd">
<prefer-application-packages>
<package-name>com.google.common.*</package-name>
</prefer-application-packages>
</weblogic-application>
来源:https://stackoverflow.com/questions/37452023/java-lang-nosuchmethoderror-during-elastic-search-start