I\'ve been having problems trying to call an EJB\'s method from a Java Application Client. Here is the code.
EJB Remote Interface
package com.test;
impo
Actually, your problem is not the lookup of the JNDI reference of your bean or you would get something like that:
Caused by: javax.naming.NameNotFoundException: ejb/HelloBean not found
No, here, I suspect a simple classpath problem, you're simply missing some jar on the classpath of your client project. With GlassFish v3, adding $GF_HOME/modules/gf-client.jar
should be enough as mentioned in How do I access a Remote EJB component from a stand-alone java client? in GlassFish's EJB FAQ (my understanding is that this jar is supposed to replace $GF_HOME/lib/appserv-rt.jar
which is there for compatibility reasons with GFv2). It is however important to refer the gf-client.jar
from the GlassFish installation directory or the jars declared in its manifest won't be found.
gf-client.jar
refers to many other .jars from the GlassFish installation directory so it is best to refer to it from within the installation directory itself rather than copying it (and all the other .jars) to another location.
Once you'll have this fixed, you should be able to lookup your bean using the JNDI names that GlassFish outputs in the logs. I'd suggest to use the new portable global JNDI names from Java EE 6.
Just in case, the What is the syntax for portable global JNDI names in EJB 3.1? entry from the GlassFish EJB FAQ provides a nice summary of this new convention. And if you want more information, check out: http://blogs.oracle.com/MaheshKannan/entry/portable_global_jndi_names.