WebSphere 7. Inject EJB from another application

g4rf0x

New Member
I am trying to inject an EJB with the @EJB annotation:
  • when I inject an EJB into another EJB in the same ear it works fine.
  • when I inject an EJB into another EJB from another ear in the sameserver I get an exception:
\[quote\] EJB threw an unexpected (non-declared) exception during invocation of method "sayHello". Exception data: javax.ejb.EJBException: Injection failure; nested exception is: com.ibm.ejs.container.EJBNotFoundException: EJB with interface com.mycompany.myapp.ejb.test2 not present in application myapp1\[/quote\]I'm using WebSphere 7 and EJB 3.0. When I'm doing a jndi lookup myself, it works fine. How do I let the container know from where to inject my remote beans?myapp1.ear contains the following : myapp1.jar (where the EJB is)myapp1 EJB :\[code\]package com.mycompany.myapp1.ejb.test1;@Remotepublic interface HelloEjb1 { public String sayHello();}\[/code\]EJB Impl :\[code\]package com.mycompany.myapp.ejb.test1;@Statelesspublic class HelloEjbImpl1 implements HelloEjb1 { @EJB HelloEjb2 helloEjb2; @Override public String sayHello() { return HelloEjb2.sayHello(); }}\[/code\]myapp2.ear contains the following : myapp2.jar (where the EJB is)myapp2 EJB :\[code\]package com.mycompany.myapp2.ejb.test2;@Remotepublic interface HelloEjb2 { public String sayHello();}\[/code\]EJB Impl :\[code\]package com.mycompany.myapp2.ejb.test2;@Statelesspublic class HelloEjbImpl2 implements HelloEjb2 { @Override public String sayHello() { return "Hello"; }}\[/code\]
 
Back
Top