users@glassfish.java.net

Re: Lookup fails for Local Stateless Bean from web client in Glassfish V2.2

From: <glassfish_at_javadesktop.org>
Date: Sun, 26 Sep 2010 16:01:12 PDT

Thanks for the reply.

Looks like I missed the @EJB concept. I thought it should just show up in the lookup. (I realize now that there are more complex semantics going on for Local interfaces to deconflict namespaces and such.)

Oddly enough, it didn't initialize the variable with the reference though using;
        @EJB(name="MyStatelessBean")
        private MyStatelessBeanLocal beanRef;

The beanRef is null, but when I look it up explicitly using:
beanRef = (MyStatelessBeanLocal) c.lookup("java:comp/env/MyStatelessBean")
it worked fine.

I did verify that it would not work unless the ejb and the war were in the same ear unless I used the Remote interface.

I'm still puzzled why it worked in one case without the @EJB annotation and not in an ear. (My theory is that there was probably a configuration file generated by NetBeans 6.7.1 and not 6.8 or 6.9 that I missed. I might have generated the working one with a different version of NetBeans or there is something else magical going on to have made it work.

Nonetheless, I can resort to the Remote interface if I don't want to use an ear. I heard or read somewhere that Glassfish would use an optimized serialization scheme if it detected that the EJB and the client were running in the same VM so maybe it doesn't matter a whole bunch. (Ideally, the application server would spare the developer from having to make a decision on this and just do the most optimal thing depending on the deployment and eliminate the concept of @Local entirely!)

Thanks!

Rob
[Message sent by forum member 'rrr6399']

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