I have deployed an ejb in a war file(not an ear file).
I have successfully consumed an ejb deployed in an ear file previously but now I am getting javax.naming.NameNotFoundException because my EJB is hosted in the war file. If my web app is called SpeechServices and the bean is under com.xyz.ejb package and its name is Service then what will be the JNDI lookup string i should be using?
I am using the following right now.
ServiceRemote remote = (ServiceRemote) ct.lookup("SpeechServices/Service/remote-com.xyz.ejb.ServiceRemote");
Please help me rectify the error in above statement.
My full code is following, which works to connect to ejbs if they are in an ear,
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "admin");
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jboss.security.jndi.JndiLoginInitialContextFactory");
InitialContext ct = new InitialContext(env);
ServiceRemote remote = (ServiceRemote) ct.lookup("SpeechServices/Service/remote-com.xyz.ejb.ServiceRemote");
System.out.println(remote.parseNotes(null, null, null));
Check the JNDI to make sure that you are using the right key. To do this: