calling an EJB from a app-client

is there some kind of law that says this has to go in the class with the main method?

@EJB

private static NumberEntityFacadeRemote numberEntityFacade;

because when its in the class with the main method, it works fine, but if i move it over to the class where i need to use it, i get a nullpointer exception

Cheers,

Derek Knapp

[363 byte] By [kingsoba] at [2007-11-27 4:14:29]
# 1
Seem to be much alike the problem I posted in this thread: http://forum.java.sun.com/thread.jspa?threadID=5173219
sammaesa at 2007-7-12 9:20:52 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

In Java EE 5, the environment annotations (@EJB, @Resource, @PersistenceContext, etc.) are only

supported on certain managed classes, such as EJB bean classes, servlets, JSF ManagedBeans, and Application Client main classes.

So, in the case of annotations for Application Client components, yes, you need to use the Application

Client main class.The reason the field/method annotations need to be marked as static is that the

entry point for an Applicaiton Client is the main method.In order for the container to ensure that

injection has taken place before main() is called, the container must have class-level (static) field/methods to manipulate.

--ken

ksaksa at 2007-7-12 9:20:52 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...