Weblogic Guava issue when deploying application

后端 未结 6 1808
天涯浪人
天涯浪人 2020-12-19 23:51

I\'m trying to deploy an application to a weblogic server, and I get the following error.
I have guava.jar in my classpath, I tried with all the latest versions I tried

相关标签:
6条回答
  • 2020-12-20 00:10

    Is it a WAR project? Or is it just a EJB jar?

    If the latest one, you've got a few options:

    • wrap your jar file into a EAR and deliver Guava's jar in it
    • add Guava's jar to the library folder of your AS
    • merge your jar file with Guava's one. For example, you can use Maven Shade Plugin if you're a Maven guy
    0 讨论(0)
  • 2020-12-20 00:15

    I ran across this issue as well, unfortunately altering the weblogic.xml didn't work for me. What did work, was dropping the guava-14.0.1.jar into $JAVA_HOME/jre/lib/endorsed (create this directory if it doesn't exist.)

    One other word of caution: at first I tried using the more recent guava-18 - this caused a compatibility issue the other way (IllegalAccessError on MapMaker.makeComputingMap - more details here). Guava 14.0.1 seems to hit the sweet spot for me - the MapMaker class is old enough to satisfy WebLogic while the MoreExecutors class is new enough to make the Cassandra Java driver work (which is how I stumbled upon this issue.)

    0 讨论(0)
  • 2020-12-20 00:23

    It seems this a recurring question ([1], [2], [3]). I, myself, have stumbled upon this same problem. Weblogic is loading first it's own version of the (outdated) guava lib confliting with your applcation's version.

    The solution is to add the prefer-application-packages to your weblogic.xml or weblogic-application.xml:

    <wls:container-descriptor>
        <wls:prefer-application-packages>
                <wls:package-name>com.google.common.*</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor>
    
    0 讨论(0)
  • 2020-12-20 00:23

    I faced the similar issue. 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"                            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>
    
    0 讨论(0)
  • 2020-12-20 00:23

    I managed to solve this problem using both files: weblogic-application.xml in ear and weblogic.xml in war

    This is weblogic-application.xml in ear -> src/main/application/META-INF/

    <?xml version="1.0" encoding="UTF-8"?>
    <wls:weblogic-application
        xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.4/weblogic-application.xsd">
        <wls:prefer-application-packages>
            <wls:package-name>com.google.common.*</wls:package-name>
        </wls:prefer-application-packages>
    </wls:weblogic-application>
    

    This is weblogic.xml in war -> src/main/webapp/WEB-INF/

    <?xml version="1.0" encoding="UTF-8"?>
    <wls:weblogic-application
        xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.4/weblogic-application.xsd">
        <wls:prefer-application-packages>
            <wls:package-name>com.google.common.*</wls:package-name>
        </wls:prefer-application-packages>
    </wls:weblogic-application>
    
    0 讨论(0)
  • 2020-12-20 00:29

    It looks like you're running against a different version of Guava than you compiled against. Possibly you are running against multiple versions of Guava, and you are randomly getting the wrong one. This may be happening if one of your other dependencies has wrongly bundled Guava.

    To figure out where this copy of MoreExecutors is coming from, I've heard that you can find it reflectively by using this snippet in UserServer:

    MoreExecutors.class.getProtectionDomain().getCodeSource().getLocation()
    
    0 讨论(0)
提交回复
热议问题