簡體   English   中英

升級到Weblogic 12c后,依賴項注入錯誤

[英]Dependency Injection error after upgrading to Weblogic 12c

我最近從Weblogic 11g升級到12c。 當MyOtherBean嘗試使用@EJB批注注入MyStartupBean時,在標准輸出中出現此錯誤:

 [exec] <Mar 6, 2017, 9:39:45,547 AM EST> <Warning> <EJB> <BEA-010065> <MessageDrivenBean threw an Exception in onMessage(). The exception is:
 [exec]  javax.enterprise.inject.InjectionException: Exception trying to inject java EE injection point into class: com.foo.My.cache.ejb.MyOtherBean..
 [exec] javax.enterprise.inject.InjectionException: Exception trying to inject java EE injection point into class: com.foo.My.cache.ejb.MyOtherBean.
 [exec]     at com.oracle.injection.integration.ModuleContainerIntegrationService.performJavaEEInjection(ModuleContainerIntegrationService.java:405)
 [exec]     at com.oracle.injection.provider.weld.WeldInjectionServicesAdapter.aroundInject(WeldInjectionServicesAdapter.java:49)
 [exec]     at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46)
 [exec]     at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:72)
 [exec]     at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:121)
 [exec]     Truncated. see log file for complete stacktrace
 [exec] Caused By: com.bea.core.repackaged.springframework.beans.factory.BeanCreationException: Dependency injection failure: can't inject the value 'com.foo.My.common.ejb.MyStartupBean_pqx8ri_Impl@39dc616' into the field 'private com.foo.My.common.interfaces.MyStartup com.foo.My.cache.ejb.MyOtherBean.startup'; nested exception is java.lang.IllegalArgumentException: Can not set com.foo.My.common.interfaces.MyStartup field com.foo.My.cache.ejb.MyOtherBean.startup to com.sun.proxy.$Proxy352
 [exec]     at com.oracle.pitchfork.inject.FieldInjection.apply(FieldInjection.java:45)
 [exec]     at com.oracle.pitchfork.inject.Jsr250Metadata.performInjection(Jsr250Metadata.java:228)
 [exec]     at com.oracle.pitchfork.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:215)
 [exec]     at com.oracle.pitchfork.inject.Jsr250Metadata.inject(Jsr250Metadata.java:197)
 [exec]     at com.oracle.injection.integration.ModuleContainerIntegrationService.performJavaEEInjection(ModuleContainerIntegrationService.java:398)
 [exec]     Truncated. see log file for complete stacktrace
 [exec] Caused By: java.lang.IllegalArgumentException: Can not set com.foo.My.common.interfaces.MyStartup field com.foo.My.cache.ejb.MyOtherBean.startup to com.sun.proxy.$Proxy352
 [exec]     at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
 [exec]     at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
 [exec]     at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
 [exec]     at java.lang.reflect.Field.set(Field.java:764)
 [exec]     at com.oracle.pitchfork.inject.FieldInjection.apply(FieldInjection.java:43)
 [exec]     Truncated. see log file for complete stacktrace

這是MyStartup界面:

@Remote
public interface MyStartup extends my.base.BaseObj
{
   public java.util.Collection getX( ) ;
   public java.util.Collection getY( ) ;
}

還有MyStartupBean ejb:

@Stateless
@CallByReference
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
@TransactionManagement(TransactionManagementType.CONTAINER)
public class MyStartupBean extends BaseSessionBean implements MyStartup
{
   public java.util.Collection getX( ){
        //do stuff
   }

   public java.util.Collection getY( ){
        //do stuff
   }
}

最后是MyOtherBean類,它調用MyStartup接口/ MyStartupBean ejb:

@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic") }, mappedName="jms/CacheRefreshTopic")
@MessageDestinationConfiguration(connectionFactoryJNDIName="jms/CacheRefreshCF")
@TransactionAttribute(value=TransactionAttributeType.SUPPORTS)
@TransactionManagement(value=TransactionManagementType.CONTAINER)
public class MyOtherBean implements MessageListener
{
    ...
    @EJB private MyStartup startup;
    ...
}

為什么將MyStartup標記為@Remote,但是您嘗試使用@EJB注釋將其實現者注入為本地bean?

在將標記注釋更改為@Local之后 ,該代碼已開始成功部署在我的Oracle WebLogic 12.2.1.2.0域上。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM