升级到Weblogic 12c后的依赖注入错误

时间:2017-03-06 20:27:21

标签: java dependency-injection weblogic weblogic12c java-ee-7

我最近从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
   }
}

最后调用MyStartup接口/ MyStartupBean的MyOtherBean类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;
    ...
}

1 个答案:

答案 0 :(得分:0)

为什么 MyStartup 标记为 @Remote ,但您正尝试使用 @EJB 注释将其实施者注入本地bean ?

将标记注释更改为 @Local 后,代码已开始在 Oracle WebLogic 12.2.1.2.0 域中成功部署。