Accessing Remote EJBs

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Accessing Remote EJBs

Steve Hostettler
Hi all, First a disclaimer: I am new to geronimo. My projects are organized as follows:
EAR1
 EJB1 Project that has a SLSB with a local/remote interface
 WEB 1 that uses the local interface of EJB1
so far so good. Now I have a second EAR
EAR2
  WS1 project that uses the remote interface of EJB1.
EAR2 will be most likely on the same server as EAR1 (but that is still under discussion) From WS1 I can access to EJB1 with a jndi lookup:
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,     
         "org.apache.openejb.client.RemoteInitialContextFactory");
prop.put("java.naming.provider.url", "ejbd://localhost:4201");

Context context = new InitialContext(prop);

mStudentService = (StudentServiceRemote) context.lookup("StudentServiceJPAImplRemote");
This does work but I do not like it for testing reasons. I would like to be able to use the @Inject coupled with an @Produces Something like Class1:
@Inject       
private StudentServiceRemote mStudentService;
ServiceLocator:
@Produces
public StudentServiceRemote locateStudentService() {
try {
	
    .....
	} catch (NamingException e) {
			throw new RuntimeException(e);
}
}
The problem is that the producer does not work, it simply does not use it. Nevertheless if I use a producer for POJO (not an EJB) it does work. Furthermore, I did not manage to inject the remote EJB with @EJB(lookup="....") I did find the tutorials and tried them but without success. Any idea? Manay thanks in advance