ejb@glassfish.java.net

How to lookup a Local/Remote EJB from a servlet? (ie. Local/Remote EJB access, without the _at_EJB annotation)

From: Drayton Brown <draytonbrown_at_gmail.com>
Date: Tue, 28 Oct 2008 15:52:30 +0000

Hi

I'm trying to implement a EJB factory for BlazeDS, an update to this
library:
http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&loc=en_us&extid=1089970

This requires that I be able to *dynamically* instanciate an EJB. In the
library above this is done like this:

         Context ctx = new InitialContext();
         Object res = ctx.lookup( <EJB Name> );

Unfortunately, this does not seem to work anymore. I believe this is due to
some changes in the servlet specification. (Apparently it worked with
servlet 2.4, but it doesn't with 2.5).
At the moment my application only allows direct injection of EJBs via the
@EJB annotation, which is not useful at all for what I want to do.

I would prefer to do this using a local EJB, but if all else fails, I am
open to switching to remote EJBs.

Your help is greatly appreciated so, thanks in advance!

Regards
Drayton