users@glassfish.java.net

Re: Deploy Problems

From: <glassfish_at_javadesktop.org>
Date: Fri, 03 Aug 2007 07:43:59 PDT

Hi, Danny.

OK, I'm embarrassed to say that I should have thought of this before.

The problem is that in app clients the Java EE spec calls for injection to be supported only on the client's main class, and only on static elements. Because the @EJB annotation is on an element in a class other than the main class when run in the context of the client, the client-side injection handling does not deal with it.

I tried the following and it worked for me while preserving what I think is your general design approach.

1. I added this new constructor to Menue:

  public Menue(MenueFacadeRemote facade) {
      menueFacade = facade;
  }

2. I added this declaration to the app client's Main class:

  @EJB (name="MenueFacade")
  private static MenueFacadeRemote menueFacade;

(It is the same as the declaration in Menue except this one is static, as required by the Java EE spec to support injection.)

3. I changed the line in the client main method to instantiate the Menue to be this:

    Menue aMenue = new Menue(menueFacade);

This displayed the Hello World dialog box successfully.

This approach is a little messy, but it does resolve the problem.

Please let us know if this works for you as well.

- Tim
[Message sent by forum member 'tjquinn' (tjquinn)]

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