6 Replies Latest reply on May 8, 2003 12:39 AM by oli

    NameNotFoundException JNDI Problem

    oli

      Hi all,

      I have a problem, does many people have, when you have a look with google. But i didn't find a solution.
      javax.naming.NameNotFoundException: HelloServer not bound
      Why does is the name form the EJB not found
      I looked under: http://localhost:8080/jmx-console/index.jsp --> service=JNDIView --> java.lang.String list()
      What i have to find? I don't see HelloServer
      What's wrong?

      I'm working with:
      - jboss-3.2.1_tomcat-4.1.24
      - eclipse 2.1
      - eclipse plugin: EASIE jboss version 1.2 (good thing)

      Server Client
      - jdk1.4.1_1 - jdk1.4.1_1
      - j2sdkee1.4 - log4j.jar
      - jbossall-client.jar


      JBoss-Protocol
      ---------------------
      15:31:35,016 INFO [URLDeploymentScanner] Started
      15:31:35,146 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/conf/jboss-service.xml
      15:31:35,156 INFO [Server] JBoss (MX MicroKernel) [3.2.1 (build: CVSTag=JBoss_3_2_1 date=200305041533)] Started in 38s:169ms
      15:33:16,844 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/HelloServer.jar
      15:33:16,894 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/HelloServer.jar

      Server-Side
      ---------------
      package test.server;
      import java.rmi.RemoteException;
      import javax.ejb.EJBObject;
      public interface HelloServer extends EJBObject { public String sayHello() throws RemoteException; }

      package test.server;
      import java.rmi.RemoteException;
      import javax.ejb.CreateException;
      import javax.ejb.EJBHome;
      public interface HelloServerHome extends EJBHome {
      HelloServer create() throws RemoteException, CreateException; }

      package test.server;
      import java.rmi.RemoteException;
      import javax.ejb.EJBException;
      import javax.ejb.SessionBean;
      import javax.ejb.SessionContext;
      public class HelloServerBean implements SessionBean {
      public void ejbCreate(){}
      public String sayHello() throws RemoteException{ return "Hello World. This is your sessionbean speaking!";}
      public void setSessionContext(SessionContext arg0) throws EJBException, RemoteException { }
      public void ejbRemove() throws EJBException, RemoteException {}
      public void ejbActivate() throws EJBException, RemoteException {}
      public void ejbPassivate() throws EJBException, RemoteException {}}

      ejb-jar.xml
      --------------
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <!DOCTYPE ejb-jar PUBLIC
      "-//SUN Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
      "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
      <ejb-jar>
      <enterprise-beans>
      <!-- Session-Beans -->

      helloWorld Session Bean example.
      <display-name>HelloWorldServerDisplayName</display-name>
      <ejb-name>HelloWorldServer</ejb-name> <!--Matches with JBoss.xml -->
      test.server.HelloServerHome
      test.server.HelloServer
      <ejb-class>test.server.HelloServerBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      </enterprise-beans>
      </ejb-jar>

      JBoss.xml
      -------------
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <!DOCTYPE jboss PUBLIC
      "-//JBoss//DTD JBOSS 3.0//EN"
      "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">

      <enterprise-beans>

      <ejb-name>HelloWorldServer</ejb-name> <!-- Matches ejb-jar.xml -->
      <jndi-name>ejb/HelloServer</jndi-name>

      </enterprise-beans>


      Client-Side
      ---------------
      package test.client;
      import java.rmi.RemoteException;
      import java.util.Properties;
      import javax.ejb.CreateException;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import test.server.HelloServer;
      import test.server.HelloServerHome;

      public class HelloClient {
      public static void main(String[] args) {

      Properties props = new Properties();
      props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      props.put("java.naming.provider.url", "localhost:1099");

      try {
      InitialContext ctx = new InitialContext(props);
      HelloServerHome theHelloHome = (HelloServerHome) ctx.lookup("ejb/HelloServer");
      HelloServer theHelloServer = (HelloServer) theHelloHome.create();
      System.out.println(theHelloServer.sayHello());
      } catch (CreateException e) {
      System.out.println("Can not create a bean: " + e);
      e.printStackTrace();
      } catch (NamingException e) {
      System.out.println("Error using Name Service: " + e);
      e.printStackTrace();
      } catch (RemoteException e) {
      System.out.println("Trouble with remote connection: " + e);
      e.printStackTrace();
      } catch (Exception e) {
      System.out.println("Exception: " + e);
      e.printStackTrace();
      } } }

      Thank's Oli

        • 1. Re: NameNotFoundException JNDI Problem

          You put your deployment descriptors in the wrong
          place.

          The need to go in
          myejb.jar/META-INF

          Maybe you have "meta-inf" or some other case?
          Try jar -tf myejb.jar

          Regards,
          Adrian

          • 2. Re: Server Okay, Client make problems  NameNotFoundException
            oli

            Hi warjort,

            I'm a stupid boy. You are right.
            I have a spelling mistake. MET-INF as META-INF
            The JBoss had the HelloServerBean deployed.

            With the HelloClient, I have the old problem:
            javax.naming.NameNotFoundException: HelloServer not bound
            I don't no why, something looks okay.

            C:\jboss-3.2.1_tomcat-4.1.24\server\default\deploy\HelloServer.jar

            jar -tf HelloServer.jar
            -----------------------------------------
            META-INF/MANIFEST.MF
            test/server/HelloServer.class
            test/server/HelloServerBean.class
            test/server/HelloServerHome.class
            META-INF/JBoss.xml
            META-INF/ejb-jar.xml
            META-INF/ejb-jar_2_0.dtd

            JBoss-Protocol
            --------------------
            13:25:10,475 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/conf/jboss-service.xml
            13:25:10,475 INFO [Server] JBoss (MX MicroKernel) [3.2.1 (build: CVSTag=JBoss_3_2_1 date=200305041533)] Started in 39s:631ms

            13:26:20,674 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/HelloServer.jar
            13:26:21,095 INFO [EjbModule] Creating
            13:26:21,135 INFO [EjbModule] Deploying HelloWorldServer
            13:26:21,175 INFO [StatelessSessionContainer] Creating
            13:26:21,175 INFO [StatelessSessionInstancePool] Creating
            13:26:21,175 INFO [StatelessSessionInstancePool] Created
            13:26:21,185 INFO [StatelessSessionContainer] Created
            13:26:21,185 INFO [EjbModule] Created
            13:26:21,195 INFO [EjbModule] Starting
            13:26:21,195 INFO [StatelessSessionContainer] Starting
            13:26:21,415 INFO [StatelessSessionInstancePool] Starting
            13:26:21,415 INFO [StatelessSessionInstancePool] Started
            13:26:21,425 INFO [StatelessSessionContainer] Started
            13:26:21,425 INFO [EjbModule] Started
            13:26:21,425 INFO [EJBDeployer] Deployed: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/HelloServer.jar
            13:26:21,455 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/HelloServer.jar


            service=JNDIView
            ------------------------
            Ejb Module: HelloServer.jar
            java:comp namespace of the HelloWorldServer bean:
            +- env (class: org.jnp.interfaces.NamingContext)

            Global JNDI Namespace
            +- HelloWorldServer (proxy: $Proxy32 implements interface test.server.HelloServerHome,interface javax.ejb.Handle)

            Thanx, Oli

            • 3. Re: Server Okay, Client make problems  NameNotFoundException

              You need to lookup HelloWorldServer

              (although from your previous descriptors it looks like you bind it under "ejb/HelloServer" but the JNDIView output doesn't show that)

              • 4. Re: Server Okay, Client make problems  NameNotFoundException
                oli

                Hi Juha,

                I'm using Eclipse for develop with the Genuitec EASIE JBoss Plugin to start the JBoss in Eclipse2.1.
                Is it a problem, when I start the Client in Eclipse as Java-Application. I'm think not, but I don't now it exactly.

                I have used any variations for solving the lookup-Problem, but nothing helps.

                javax.naming.NameNotFoundException: HelloServerWorld not bound

                ctx.lookup("HelloServerWorld");
                ctx.lookup("ejb/HelloServerWorld");
                ctx.lookup("/ejb/HelloServerWorld");

                ctx.lookup("HelloServer");
                ctx.lookup("ejb/HelloServer");
                ctx.lookup("/ejb/HelloServer");

                Thanx,
                Oli

                • 5. Re: Server Okay, Client make problems  NameNotFoundException

                  Global JNDI Namespace
                  +- HelloWorldServer (proxy: $Proxy32 implements interface test.server.HelloServerHome,interface javax.ejb.Handle)

                  Try HelloWorldServer.

                  What you see in your Global JNDI Tree is what you can lookup from the client. Everything else will fail.

                  • 6. Re: :-) Server Okay, Client Okay
                    oli

                    Hi Juha,

                    it work's :-), cool
                    ctx.lookup("HelloWorldServer");
                    Hello World. This is your sessionbean speaking!

                    Your last sentence, have bring light in my stupid Disaster.

                    Thanx,
                    Oli

                    and now for the next week, merge a database in JBoss