开发者

Endpoint for an EJB deployed on JBOSS

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开发者_Go百科 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:

  1. Access JBoss:service=JNDIView in JMX-Console
  2. invoke list() method
  3. Verify whether your EJB is bound properly and confirm that the key you are using is correct


Verify that you have updated the web.xml to use

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0"> 

I think the spec says that EJBs are not processed in a Java EE 6 way if this isn't done in your web.xml.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜