Hello I am facing this exception when trying to lookup the jndi name in order to do a junit test in my JavaEE project using Wildfly9 server:
javax.naming.NameNotFoundException: phenomenon-ejb/ClientSessionBean!utilities.CllientSessionBeanRemote -- service jboss.naming.context.java.jboss.exported.phenomenon-ejb."ClientSessionBean!utilities.CllientSessionBeanRemote"
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:184)
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:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
This is the junit code I wrote:
public class JunitTester {
@org.junit.Test
public void Test() throws NamingException {
Context ctx = new InitialContext();
CllientSessionBeanRemote gest = (CllientSessionBeanRemote) ctx.lookup("/phenomenon-ejb/ClientSessionBean!"+ CllientSessionBeanRemote.class.getCanonicalName());
System.out.println(gest.Verify_No_Existence("Multiskan"));
}
}
Here is my jndi.properties file:
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
java.naming.factory.initial=org.jboss.naming.remote.client.InitialContextFactory
java.naming.provider.url=http-remoting://localhost:8080
jboss.naming.client.ejb.context=true
jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
And this is the output showed in the console when I deploy the application:
java:global/phenomenon-ear/phenomenon-ejb/ClientSessionBean!utilities.ClientSessionBean
java:app/phenomenon-ejb/ClientSessionBean!utilities.ClientSessionBean
java:module/ClientSessionBean!utilities.ClientSessionBean
java:global/phenomenon-ear/phenomenon-ejb/ClientSessionBean!utilities.CllientSessionBeanRemote
java:app/phenomenon-ejb/ClientSessionBean!utilities.CllientSessionBeanRemote
java:module/ClientSessionBean!utilities.CllientSessionBeanRemote
java:global/phenomenon-ear/phenomenon-ejb/ClientSessionBean!utilities.CllientSessionBeanLoacal
java:app/phenomenon-ejb/ClientSessionBean!utilities.CllientSessionBeanLoacal
java:module/ClientSessionBean!utilities.CllientSessionBeanLoacal
By the way the handshake is currectly done and my only problem is how to know the jndiname or why is the server not recognizing the one I wrote:
INFO: JBoss Remoting version 4.0.5.Beta1
juil. 22, 2020 2:08:34 PM org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: EJBCLIENT000017: Received server version 2 and marshalling strategies [river]
juil. 22, 2020 2:08:34 PM org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@757942a1, receiver=Remoting connection EJB receiver [connection=Remoting connection <260479b4>,channel=jboss.ejb,nodename=desktop-k8fvkco]} on channel Channel ID a12ae3eb (outbound) of Remoting connection 651ca769 to localhost/127.0.0.1:8080
any advice could help, thanks.
The Wildfly Naming subsystem bind entries into the following global JNDI namespaces:
java:global
java:jboss
java:
However:
Only entries within the java:jboss/exported context are accessible over remote JNDI.
Make sure your business objects are "properly exposed" with the @Remote annotation.