4 July 2011

@EJB Annotation in EJB Client

Problem:

App server is JBoss, I created the Jar file for the bean class and interface in the right directory. Now I created a simple client using EJB annotations, but I am getting a NullPointerException.

Solution:

EJB annotation is an incejction, it is supposed to be deployed on the app server and then executed in an Application Client Container (ACC) so that injection can occur. Starting the ACC requires an application server specific command.


The following wiki explains the usage of the ACC in JBoss (how to package, deploy and launch an ACC): How to use an application client in JBoss-5.

If you don't want to use an Application Client Container and instead just run the application client class through a java command, injection won't be possible and you'll have to perform a JNDI lookup.

And in both cases, you'll have to provide and use a remote business interface for your bean.

No comments:

Post a Comment