users@glassfish.java.net

Re: Interop with Glassfish and other application servers

From: Stephen Connolly <stephen.alan.connolly_at_gmail.com>
Date: Wed, 5 Dec 2007 14:32:46 +0000

Just a stupid question:

Are you sure that all your @EJB fields are static fields in the class
with public static void main(String[]);

EJB injection only works for App clients in the container created
class (i.e. the one with static void main in the case of an App
Client)

-Stephen

On Dec 5, 2007 9:08 AM, <glassfish_at_javadesktop.org> wrote:
> Hi Cheng,
>
> sorry for the late answer, was kinda busy with other work :-/
>
> The reason why i started with the ugly variant of putting everything in the code, is that i have to evaluate all possible ways to look up the EJB on the other servers. But now that i got that working i was also trying the recommended ways, like using deployment descriptors as you posted before. Using the lookup example you posted worked kinda out of the box, thanks for that, saved me some time.
>
> But for some reason i cannot get it to work with EJB injection, i always get a NullPointerException when trying to access the objects methods. I was toying around a lot with different combinations and then decided to use the Sless example from the Glassfish site (https://glassfish.dev.java.net/javaee5/ejb/examples/Sless.html) and to replace the EJB there with mine. In the end i was able to call my EJB from the appclient class provided with the example, calling it in exactly the same way as i do in my servlet. So i basically use the same EJB and the same calling code but it only works using the appclient tool from the command line and not from within the web container. Am i missing some server configuration there? The weird thing is that i can call the EJB from the web container using deployment descriptors.
>
> Sorry if i am just being stupid here, i was searching the net a lot about this but every resource i found, just told me that it should be done exactly the same way as i am doing it, at least when i understood them correctly:
>
> - annotate the interface as Remote
> - annotate the implementing bean as Stateless
> - annotate the member of the interface type in the client side class as EJB
> - remove the entries referring to this EJB from web.xml
> - remove the sun-web.xml as a whole
>
> Any idea, what i am doing wrong or where i could look it up?
>
> Thanks, Chris
> [Message sent by forum member 'candlejack' (candlejack)]
>
> http://forums.java.net/jive/thread.jspa?messageID=248588
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>