users@glassfish.java.net

RE: question about _at_ejb injection on ACC

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Mon, 1 Feb 2010 16:20:58 +0000

Hi Luca,

 

Take a look at this -

 

Eve,

It's important to note that the Java EE 5 spec specifies that injection take place only in "managed" classes. In the app client, there are only two managed classes: the main class (as specified either in the manifest or on the appclient command line) and the optional log-in callback class.

Also, the spec also mandates that in the app client main class only static elements can be injected.

Here is one general approach that some people find works for them:

1. Define the injected static fields on the app client's main class:

@EJB
private static UsersRemote usersRemote;

2. Write a static accessor method on the app client's main class:
static UserRemote getUserRemote() {
    return usersRemote;
}

3. From anywhere in any of the classes in your app client use Main.getUserRemote() when you need to use the EJB.

- Tim


 

That's how I resolve my issues. It seems the injection only works with the

main class but you may get away with it if you implement it as Tim mentioned

above.

 

Thanks

 

eve
 
> Date: Mon, 1 Feb 2010 07:10:16 -0800
> From: glassfish_at_javadesktop.org
> To: users_at_glassfish.dev.java.net
> Subject: Re: question about @ejb injection on ACC
>
> Hi Luca,
>
> Injection in the ACC is only defined for classes that are managed by the container. The main class falls into that category but the JFrame doesn't.
>
> --ken
> [Message sent by forum member 'ksak' (kenneth.saks_at_sun.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=384055
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
                                               
_________________________________________________________________
Got a cool Hotmail story? Tell us now
http://clk.atdmt.com/UKM/go/195013117/direct/01/