2017-03-06 97 views
0

我最近從Weblogic 11g升級到12c。獲得在標準輸出這個錯誤時MyOtherBean嘗試使用@EJB註釋注入MyStartupBean:升級到Weblogic 12c後依賴注入錯誤

[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 '[email protected]' 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; 
    ... 
} 

回答

0

爲什麼MyStartup標記爲@Remote但你試圖注入他的實施者與使用@EJB註釋本地豆?

後,我改變了標記註釋@Local,代碼已開始被成功部署在我的Oracle WebLogic 12.2.1.2.0域。