1
我有一個多耳項目。一些EJB駐留在project1.ear中,我需要在project2.ear中使用它。從其他.ear注入@Stateless EJB
我想以下幾點:
@Remote
public interface MyService {
public static final String JNDI_NAME = "service/MyService";
// methods
}
@Stateless(name = MyService.JNDI_NAME, mappedName = MyService.JNDI_NAME)
public class MyServiceImpl implements MyService {
// implementations...
}
然後,在一些project2.ear類,我注入這樣的EJB:
@Stateless(name = "other/Service")
public class OtherServiceImpl implements OtherService{
@EJB(mappedName = MyService.JNDI_NAME)
private MyService service;
}
但是我得到了很多 「FailedToConstructException」 的和EJB相關的異常,原因如下:
Caused by: javax.naming.NameNotFoundException: service/MyService -- service jboss.naming.context.java.service.MyService
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:113)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)
at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_05]
at org.jboss.as.ejb3.deployment.processors.EjbLookupInjectionSource$1.getReference(EjbLookupInjectionSource.java:82) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
... 104 more
我在做什麼錯?
在此先感謝。
謝謝,我把它只有mappedName和它的工作就像老闆。 – caarlos0
@ caarlos0 - 很高興幫助。 –