Skip to main content

Command line Java client for EJB 3 stateless session bean

3 replies [Last post]
ejb3user
Offline
Joined: 2005-12-14

Anybody got a snippet of code that needs to be used in Java client to lookup a EJB 3 stateless session bean using RMI or application client context ?

-ejb3user

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dochez
Offline
Joined: 2003-06-10

Hello

You can find such examples in the
appserv-tests/devtests/ejb/ejb30 directory

in particular, you can find some injection or some jndi lookup in the core or adapted client examples.

Hope this helps.

ejb3user
Offline
Joined: 2005-12-14

Thanks for the helpful tip.
I got the client working using simple InitialContext and looking up the bean, but when I tried to use @EJB annotation in the client, I was getting NPE, when the client was trying to get a handle.

Is @EJB annotaion support in command line clients or the injection would only work when the client is also in the same VM (JSP, JSF, Servlet ....) ??

thanks
-ejb3user

vbkraemer
Offline
Joined: 2003-09-03

I think injection is supported in the app client container.

You can read about it in this document.

If you want to use injection, you may want to use the Java Web Start support for application clients, that is discussed in the same document. It makes the app deployment across your enterprise much easier.