jndi on jboss for ejb

Discussions

EJB design: jndi on jboss for ejb

  1. jndi on jboss for ejb (5 messages)

    Hi ,

    I am new to ejb and would like to have some help in deploy the ejb on Jboss 4.0.1. How do I set the JNDI name? Right now I have ejb-jar.xml and jboss-ejb.xml.
    The application is giving a null pointer exception if I try to access the home interface. Below is teh code. Thanks for your time.

    try {
    Context ic = new InitialContext();
    Object obj = ic.lookup("SecurityApp");

     home = (SecurityHome) PortableRemoteObject.narrow(obj, SecurityHome.class);

    }catch(Exception ex){
    System.out.println("----exception occured-----");
    ex.printStackTrace();
    }

    Threaded Messages (5)

  2. jndi on jboss for ejb[ Go to top ]

    ¿Could you post the stack trace?

    Cheers and happy coding,
    Martin
  3. jndi on jboss for ejb[ Go to top ]

    Thanks Martin for trying to help me. Here is the stack trace. I am also posting the ejb-jar.xml, jboss.xml and the updated client code. Thanks again!

    /////////////ejb-jar.xml////////////////

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'
    'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

    <ejb-jar>
         <description>Security App</description>
         <display-name>Security EJB</display-name>
         <enterprise-beans>
           <session>
             <ejb-name>SecurityApp</ejb-name>
             <home>com.admin.dao.SecurityHome</home>
             <remote>com.admin.dao.SecurityObject</remote>
             <ejb-class>com.admin.dao.SecurityBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Bean</transaction-type>
           </session>
         </enterprise-beans>
    </ejb-jar>

    //////////////////////jboss.xml/////////////////
    jboss.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
    <jboss>
      <enterprise-beans>
        <session>
          <ejb-name>SecurityApp</ejb-name>
          <jndi-name>SecurityApp</jndi-name>
        </session>
      </enterprise-beans>
    </jboss>

    ///////////////////client code//////////

    Properties props = new Properties();
            props.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.jnp.interfaces.NamingContextFactory");
            props.put(Context.PROVIDER_URL, "localhost:1099");
    try {
    Context ic = new InitialContext(props);
    Object obj = ic.lookup("SecurityApp");

    home = (SecurityHome) PortableRemoteObject.narrow(obj, SecurityHome.class);

    ////////exceptions////////////////

    16:50:40,925 INFO [STDOUT] ----Security client-----
    16:50:40,925 INFO [STDOUT] javax.naming.NameNotFoundException: SecurityApp not bound
    16:50:40,925 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(Naming Server.java:491)
    16:50:40,925 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(Naming
    Server.java:499)
    16:50:40,925 INFO [STDOUT] at org.jnp.server.NamingServer.getObject(NamingS
    erver.java:505)
    16:50:40,925 INFO [STDOUT] at org.jnp.server.NamingServer.lookup(NamingServ
    er.java:278)
    16:50:40,925 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(
    Native Method)
    16:50:40,925 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N
    ativeMethodAccessorImpl.java:39)
    16:50:40,925 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo
    ke(DelegatingMethodAccessorImpl.java:25)
    16:50:40,925 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:5
    85)
    16:50:40,925 INFO [STDOUT] at sun.rmi.server.UnicastServerRef.dispatch(Unic
    astServerRef.java:294)
    16:50:40,925 INFO [STDOUT] at sun.rmi.transport.Transport$1.run(Transport.j
    ava:153)
    16:50:40,925 INFO [STDOUT] at java.security.AccessController.doPrivileged(N
    ative Method)
    16:50:40,925 INFO [STDOUT] at sun.rmi.transport.Transport.serviceCall(Trans
    port.java:149)
    16:50:40,925 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport.handleMess
    ages(TCPTransport.java:460)
    16:50:40,925 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport$Connection
    Handler.run(TCPTransport.java:701)
    16:50:40,925 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
    16:50:40,925 INFO [STDOUT] at sun.rmi.transport.StreamRemoteCall.exceptionR
    eceivedFromServer(StreamRemoteCall.java:247)
    16:50:40,925 INFO [STDOUT] at sun.rmi.transport.StreamRemoteCall.executeCal
    l(StreamRemoteCall.java:223)
    16:50:40,925 INFO [STDOUT] at sun.rmi.server.UnicastRef.invoke(UnicastRef.j
    ava:126)
    16:50:40,925 INFO [STDOUT] at org.jnp.server.NamingServer_Stub.lookup(Unkno
    wn Source)
    16:50:40,925 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(Namin
    gContext.java:544)
    16:50:40,925 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(Namin
    gContext.java:520)
    16:50:40,925 INFO [STDOUT] at javax.naming.InitialContext.lookup(InitialCon
    text.java:351)
    16:50:40,925 INFO [STDOUT] at com.admin.dao.Security
    Client.getEJBHome(SecurityClient.java:33)
    16:50:40,925 INFO [STDOUT] at com.admin.actions.View
    CompanyDispatchAction.add ViewCompanyDispatchAction.java:74)
  4. jndi on jboss for ejb[ Go to top ]

    try looking up "java:/SecurityApp", or access JNDI view in jmx-console and find the full JNDI name of the EJB in the tree.
    That should work.

    Cheers and happy coding,
    Martin
  5. jndi on jboss for ejb[ Go to top ]

    Thanks for your reply. I have resolved the naming problem by giving the jndi name as

    ejb.myapp rather than ejb/myapp.

    Thanks again for replying to my post.
  6. jndi on jboss for ejb[ Go to top ]

    Hello Priya,


    I had the same problem that you had before. I can not find EJB through JNDI. I am using JBoss4.0 tool

    Where did you change:
    ejb.myapp rather than ejb/myapp

    Many thanks for the help.

    mei