WebLogic 12c中的Guava 15.0 jar冲突

时间:2013-10-27 23:44:18

标签: guava weblogic12c

我在一个在WebLogic 12c上部署的应用程序中从guava 14.0.1更新到15.0,我在部署期间遇到了一个我无法解决的java.lang.NoSuchMethodException:

Caused By: java.lang.NoSuchMethodException: com.google.common.base.internal.Finalizer.startFinalizer(java.lang.Class, java.lang.ref.ReferenceQueue, java.lang.ref.PhantomReference)
    at java.lang.Class.getMethod(Class.java:1624)
    at com.google.common.base.FinalizableReferenceQueue.getStartFinalizer(FinalizableReferenceQueue.java:302)
    at com.google.common.base.FinalizableReferenceQueue.<clinit>(FinalizableReferenceQueue.java:90)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:266)
    at com.oracle.injection.provider.weld.BasicResourceLoader.classForName(BasicResourceLoader.java:27)
    at org.jboss.weld.bootstrap.BeanDeployer.loadClass(BeanDeployer.java:107)
    at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:77)
    at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:135)
    at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:349)
    at com.oracle.injection.provider.weld.WeldInjectionContainer.deploy(WeldInjectionContainer.java:99)
    at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:68)
    at com.oracle.injection.integration.CDIAppDeploymentExtension.activate(CDIAppDeploymentExtension.java:47)
    at weblogic.application.internal.flow.AppDeploymentExtensionFlow.activate(AppDeploymentExtensionFlow.java:37)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
    at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:61)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:586)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:148)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:114)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:339)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:846)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1275)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:442)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:176)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:550)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)

我已经在我的weblogic.xml文件中使用WebLogic prefer-application-packages类加载器过滤,如here所述,以解决WebLogic 12c中的运行时冲突,因为它似乎重新打包了旧版本的图书馆。这一直在番石榴14.0.1中工作,但在15.0中没有。

据我所知,首选com.google.common。*包应该包含所有内容。此类Finalizer类是否在类加载器过滤发生之前执行了一些特殊操作,从而尝试加载看似具有不同API的旧版本?

是否有另一种解决方案可以使用与应用程序打包在一起的guava-15.0.jar而不是服务器捆绑的内容?

2 个答案:

答案 0 :(得分:9)

open issue #1527针对此问题(Guava 15无法部署到任何JEE6容器),这是在修复this one后发生的。请加注星标和/或评论,然后等待修复(comment #33表示版本15.0.1可能会在近期发布。)

修改 同时,the issue was resolved new maven release

  

关于JEE6 / CDI 1.0

的说明      

在Guava 15.0中添加了一种解决方法,使其与CDI 1.1兼容   (用于JEE7容器)导致带有CDI 1.0的番石榴出现问题(使用过   在JEE6容器中。)

     

如果您在CDI 1.0环境中使用Guava,则应该使用   guava-15.0-cdi1.0.jar而不是普通的番石榴罐。在Maven,   依赖关系可以指定为:

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>15.0</version>
  <classifier>cdi1.0</classifier>
</dependency>

如果要在JEE 6和7服务器上部署,则必须使用Guava 13或wait until 16 is released

答案 1 :(得分:2)

作为一个附加信息,由于WL和Guava之间的混淆(尝试过Guava版本11和18),我在升级到Weblogic 12c时遇到了类似的问题。

我发现解决方案是明确更喜欢我的应用程序的lib。我在我的weblogic.xml上设置了这个:

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

查看http://docs.oracle.com/middleware/1212/wls/WLPRG/classloading.htm#WLPRG315作为参考。