I would like to know how to look up a EJB located into a WildFly server from a remote client using JNDI.
Here is what I use to initialize the context
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.PROVIDER_URL, "http-remoting://192.168.0.15:8080");
jndiProps.put("jboss.naming.client.ejb.context", true);
Context ctx = new InitialContext(jndiProps);
And this is the console output when I deploy the server:
21:08:29,352 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-10) JNDI bindings for session bean named DataBaseServiceImpl in deployment unit deployment "AnalyseExcelServeur.war" are as follows:
java:global/AnalyseExcelServeur/DataBaseServiceImpl!serveur.database.DataBaseService
java:app/AnalyseExcelServeur/DataBaseServiceImpl!serveur.database.DataBaseService
java:module/DataBaseServiceImpl!serveur.database.DataBaseService
java:jboss/exported/AnalyseExcelServeur/DataBaseServiceImpl!serveur.database.DataBaseService
java:global/AnalyseExcelServeur/DataBaseServiceImpl
java:app/AnalyseExcelServeur/DataBaseServiceImpl
java:module/DataBaseServiceImpl
I have try a lot of combination but every time I get a javax.naming.NameNotFoundException:
javax.naming.NameNotFoundException: exported/AnalyseExcelServeur/DataBaseServiceImpl!serveur.database.DataBaseService -- service jboss.naming.context.java.jboss.exported.exported.AnalyseExcelServeur."DataBaseServiceImpl!serveur.database.DataBaseService"
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I have not defined an app name nor a module name.
- The project name of the server is : AnalyseExcelServeur
- The name of the EJB is DataBaseServiceImpl
- The EJB implements DataBaseService which is located in the package serveur.database
Here is how I declare the EJB:
@Stateless
@Remote(DataBaseService.class)
public class DataBaseServiceImpl extends SessionDB implements DataBaseService
On the client side the implementation of the DataBaseService interface is located in the package compte.remote.ejb
I don't know if I have to use ejb:/appname/modulename/bean/location or just /appname/modulename/bean/location or anything else...
Maybe I have to put a file into the .war to declare the EJB...