I have an EAR application containing 3 ejbModules and 4 webModules, which is redeployed during development quite often (multiple times per day) on WebLogic 12.2.1.1 (Java EE 7). Google Guava 18.0 is used in various components within these applications.
In the 4 weblogic.xml's and 1 weblogic-application.xml I've marked the Guava packages as provided by my application instead of the version supplied by WebLogic:
<prefer-application-packages>
<package-name>com.google.common.*</package-name>
</prefer-application-packages>
During some deployments using WLST the deployment fails with this exception:
[ServerConnectionImpl.upload():862] : Uploaded app to D:\Domains\NAMED_SERVER\.\servers\AdminServer\upload\app-ear
[BasicOperation.execute():472] : Initiating deploy operation for app, app-ear, on targets:
[BasicOperation.execute():474] : PEARL_WL1
Task 62 initiated: [Deployer:149026]deploy application app-ear on NAMED_SERVER.
dumping Exception stack
Task 62 failed: [Deployer:149026]deploy application app-ear on NAMED_SERVER.
Target state: deploy failed on Server PEARL_WL1
java.lang.LinkageError: loader constraint violation: loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) previously initiated loading for a different type with name "com/google/common/base/Supplier"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at weblogic.utils.classloaders.GenericClassLoader.defineClassInternal(GenericClassLoader.java:1109)
at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:1042)
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:1034)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:986)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:83)
at weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:607)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:539)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:492)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:469)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:53)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at weblogic.ejb.container.injection.EjbComponentContributor.getCtrlIntfMethods(EjbComponentContributor.java:147)
at weblogic.ejb.container.injection.EjbComponentContributor.buildInterceptionMetadata(EjbComponentContributor.java:248)
at weblogic.ejb.container.injection.EjbComponentContributor.contribute(EjbComponentContributor.java:187)
at weblogic.ejb.container.injection.InjectionBasedEjbComponentContributor.contribute(InjectionBasedEjbComponentContributor.java:96)
at weblogic.j2ee.injection.J2eeComponentContributor.contribute(J2eeComponentContributor.java:48)
at weblogic.ejb.container.injection.EjbComponentContributor.contribute(EjbComponentContributor.java:94)
at weblogic.ejb.container.injection.InjectionBasedEjbComponentContributor.contribute(InjectionBasedEjbComponentContributor.java:130)
at com.oracle.pitchfork.server.Bootstrap.deploy(Bootstrap.java:140)
at com.oracle.pitchfork.spi.WLSBootstrap.deploy(WLSBootstrap.java:106)
at com.oracle.pitchfork.server.Bootstrap.deploy(Bootstrap.java:104)
at com.oracle.pitchfork.spi.BaseComponentBrokerImpl.initialize(BaseComponentBrokerImpl.java:48)
at com.oracle.pitchfork.spi.EjbComponentCreatorBrokerImpl.initialize(EjbComponentCreatorBrokerImpl.java:44)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.initialize(EjbComponentCreatorImpl.java:44)
at weblogic.ejb.container.injection.InjectionBasedEjbComponentCreator.initialize(InjectionBasedEjbComponentCreator.java:54)
at weblogic.ejb.container.deployer.EJBDeployer.initializeComponentCreator(EJBDeployer.java:539)
at weblogic.ejb.container.deployer.EJBDeployer.activate(EJBDeployer.java:753)
It seems that there is a Google Guava conflict after all, possible loaded twice. I've verified that my EAR only contains 1 guava.jar, in /lib.
Any ideas how to test/debug what exactly goes wrong sometimes?
[Addition]
What seems to go wrong is that one of my ejbModules uses Guava (only com.google.common.base.Supplier) I'm using Java 8, so rewriting to java.util.function.Supplier effectively removed the need for Guava on this ejbModule and fixed the deployment problem.
The question remains is WHY this problem occurred.
I did specify in weblogic-application.xml to use the Guava.jar inside the EAR.
Any ideas why I can't override Guava correctly?