12 Replies Latest reply on Nov 9, 2005 8:14 AM by rrawasi

    "JNDI name" not bound

    rrawasi

      I develope a simple EJB it work fine with sun application server now I deploy it on jboss but I get a JNDI name not bound error.
      I also add all these file to classpath when I want to compile my client:
      jnp-client.jar,jnpserver.jar,jboss-client.jar,jboss-common.jar
      plus my ejb.jar file that created from following ant script:

      <project name="EJBJBOSS" default="ejbjar">
      <property file="build.properties"/>
       <echo message="classes = ${build.classes.dir}"/>
      
       <target name="init" >
       <mkdir dir="classes"/>
       </target>
      
       <target name="compile" depends="init">
       <javac destdir="${build.classes.dir}"
       srcdir="${build.src.dir}">
       <classpath>
       <pathelement location="${compile.classpath}"/>
       </classpath>
       <include name="**/*.java"/>
       </javac>
       </target>
      
      
       <target name="ejbjar" depends="compile">
       <jar destfile="${dist.dir}/${ejbjar.name}"
       basedir="${build.classes.dir}"
       includes="${metainf}/*.xml">
       <exclude name="HelloClient.class"/>
       </jar>
       <echo message="ejb jar destination = ${dist.dir}"/>
       </target>
      </project>
      

      META-INF folder contain following jboss.xml and ejb-jar.xml:
      <?xml version="1.0"?>
      <ejb-jar
       xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
       http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
       version="2.1">
      <enterprise-beans>
      <session>
       <ejb-name>HelloBean</ejb-name>
       <home>tutorial.interfaces.HelloHome</home>
       <remote>tutorial.interfaces.Hello</remote>
       <ejb-class>tutorial.ejb.HelloBean</ejb-class>
       <session-type>Stateless</session-type>
      </session>
      </enterprise-beans>
      </ejb-jar>
      
      
      <?xml version="1.0"?>
      <jboss>
       <enterprise-beans>
       <session>
       <ejb-name>HelloBean</ejb-name><!--Matches ejb-jar.xml -->
       <jndi-name>jboss/HelloBean</jndi-name><!--Matches client code-->
       </session>
       </enterprise-beans>
      </jboss>
      


      and here is my client code:
      import javax.naming.*;
      import javax.rmi.*;
      import tutorial.interfaces.HelloHome;
      import tutorial.interfaces.Hello;
      
      
      public class HelloClient {
      
       public void go() {
       try
       {
       Properties prop = new Properties();
       prop.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
       prop.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
       prop.put("java.naming.provider.url","localhost");
       Context ic = new InitialContext(prop);
       System.out.println("from client: EJB client Start");
      
       Object ref = ic.lookup("jboss/HelloBean");
       System.out.println("JNDI name solved");
      
       tutorial.interfaces.HelloHome home=(HelloHome)PortableRemoteObject.narrow(ref,HelloHome.class);
       System.out.println("from client: home already finded");
       tutorial.interfaces.Hello sayHello = home.create();
       System.out.println(sayHello.helloing());
      
       System.out.println("from client: EJB client End");
       }
       catch(Exception ex)
       {
       ex.printStackTrace();
       }
       }
       public static void main(String[] args){
       new HelloClient().go();
       }
      }


      I saw JBOSS service=JNDIView from jmx-console but I don't find my JNDI name

      here is my error:

      from client: EJB client Start
      javax.naming.NameNotFoundException: jboss not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:253)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:534)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
      at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
      at sun.rmi.server.UnicastRef.invoke(Unknown Source)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at tutorial.client.HelloClient.go(HelloClient.java:22)
      at tutorial.client.HelloClient.main(HelloClient.java:38)

      so please help me it make me tired

        • 1. Re:
          darranl

           

          "rrawasi" wrote:

          I saw JBOSS service=JNDIView from jmx-console but I don't find my JNDI name


          If you can not find your bean using the JNDI view it only means one thing - your bean has not been deployed.

          Have you double checked it is not bound using any other name?

          What messages are displayed when you deploy your jar?

          Can you execute the command 'jar -tf jarfile.jar' against your jar and post the output here.

          • 2. Re:
            rrawasi

            thank you for your reply
            here is jboss log for make sure that my bean is deployed:
            08:45:24,395 INFO [MainDeployer] Starting deployment of package: file:/D:/Reza/JBOSS/jboss-3.2.3/server/default/deploy/helloEJB
            08:45:24,405 INFO [MainDeployer] Deployed package: file:/D:/Reza/JBOSS/jboss-3.2.3/server/default/deploy/helloEJB

            and when I issue: jar -tf myjar
            I get the following out put:
            META-INF/
            META-INF/MANIFEST.MF

            I'm sure that I don't use this name before because it is my first jar that I deployed on jboss

            • 3. Re:
              rrawasi

              maybe I find my problem it is about my jar file creation and ant script but I'm not sure

              • 4. Re:
                rrawasi

                Now I correct my jar file but it still don't find by application server.
                here is my jar content:
                META-INF/
                META-INF/MANIFEST.MF
                tutorial/
                tutorial/ejb/
                tutorial/ejb/HelloBean.class
                tutorial/interfaces/
                tutorial/interfaces/Hello.class
                tutorial/interfaces/HelloHome.class
                ejb-jar.xml
                jboss.xml

                • 5. Re:
                  rrawasi

                   

                  "rrawasi" wrote:
                  Now I correct my jar file but it still don't find by application server.
                  here is my jar content:
                  META-INF/
                  META-INF/MANIFEST.MF
                  tutorial/
                  tutorial/ejb/
                  tutorial/ejb/HelloBean.class
                  tutorial/interfaces/
                  tutorial/interfaces/Hello.class
                  tutorial/interfaces/HelloHome.class
                  META-INF/ejb-jar.xml
                  META-INF/jboss.xml


                  • 6. Re:
                    jaikiran

                    Please post contents of ejb-jar.xml and jboss.xml

                    • 7. Re:
                      jaikiran

                      Sorry, hadnt seen your first post.

                      • 8. Re:
                        jaikiran

                        Is your helloEJB a .jar file? If yes, then you will have to package it into a .ear file and place the .ear file in deploy directory. The reason why i am asking this is i did not find any application.xml file under the META-INF directory(from the contents that you posted)

                        • 9. Re:
                          darranl

                          What is output by JBoss when you deploy the latest jar with the modified structure?

                          • 10. Re:
                            rrawasi

                            within a last format I solve it thank you for your usefull information.
                            the problem is my META_INF folder and my ant build script.

                            • 11. Re:
                              rrawasi

                              within a last format I solve it thank you for your usefull information.
                              the problem is my META_INF folder and my ant build script.

                              • 12. Re:
                                rrawasi

                                within a last format I solve it thank you for your usefull information.
                                the problem is my META_INF folder and my ant build script.