Can not inject ejb from one module to jsf mbean in another module. Both modules on singe glassfish instance.
Local interface in main module:
@Local
public interface TestEJBLocal {
String getMessage();
}
Implementation in main module:
@Stateless
public class TestEJB implements TestEJBLocal {
@Override
public String getMessage() {
return "Hello EJB World";
}
}
Local interface in 3rdparty module:
@Local
public interface TestEJBLocal {
String getMessage();
}
Consumer bean in 3rdparty module:
@Named(value = "testBean")
@Singleton
public class testBean {
@EJB(lookup="java:global/mavenproject3-ear/mavenproject3-ejb-1.0-SNAPSHOT/TestEJB!com.versetty.ejb.TestEJBLocal")
private TestEJBLocal testBean;
public TestEJBLocal getTestBean() {
return testBean;
}
public void setTestBean(TestEJBLocal testBean) {
this.testBean = testBean;
}
public void doEJBCall() {
System.out.println("sdf");
testBean.getMessage();
}
}
Exception:
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Local ejb-ref name=com.versetty.web.bean.testBean/testBean,Local 3.x interface =com.versetty.web.remote.TestEJBLocal,ejb-link=null,lookup=java:global/mavenproject3-ear/mavenproject3-ejb-1.0-SNAPSHOT/TestEJB!com.versetty.ejb.TestEJBLocal,mappedName=,jndi-name=,refType=Session into class com.versetty.web.bean.testBean: Can not set com.versetty.web.remote.TestEJBLocal field com.versetty.web.bean.testBean.testBean to com.sun.proxy.$Proxy368
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:740)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:507)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:170)
at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:165)
... 78 more
Aucun commentaire:
Enregistrer un commentaire