users@glassfish.java.net

Re: Manual lookup of remote EJB in Glassfish

From: <glassfish_at_javadesktop.org>
Date: Tue, 26 Oct 2010 07:20:35 PDT

> You can look up from you webapp:
> ic.lookup("java:comp/env/StatusService");

I have just found out that this works if the EJB has already been injected somewhere else, but not if it hasn't.

From what I have discovered the @EJB annotation is doing a bit more than just looking up the reference.. But I found a little gem called EJBUtils (in glassfish-embedded-all) that solved all my remoting needs for today. This seems to do exactly what I want:

String jndiName = EJBUtils.getRemote30HomeJndiName("corbaname:iiop:localhost:3700#no.evote.service.StatusService");
Object obj = context.lookup(jndiName);
StatusService statusService = (StatusService)EJBUtils.lookupRemote30BusinessObject(obj, "no.evote.service.StatusService");

Not sure whether this is the correct way of doing it, but at least it seems to be working.

Regards,

Anders
[Message sent by forum member 'andersaab']

http://forums.java.net/jive/thread.jspa?messageID=486255