1 Reply Latest reply on Sep 15, 2003 4:28 AM by Adrian Brock

    java.naming.namenotfoundexception

    Ledyvânia Newbie

      Hi....

      i'm try to execute my client application
      and i always got only this message...
      "java.naming.namenotfoundexception: Adder not found"

      can anyone help me????

      ================
      here's my client
      ================
      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import java.util.Properties;
      import exemplo.ejb.Adder;
      import exemplo.ejb.AdderHome;

      public class BeanClient
      {
      public static void main (String args[])
      {
      //preparing properties for constructing an InitialContext object
      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.PROVIDER_URL, "localhost:1099");

      try
      {
      //Get an initial Context
      InitialContext jndiContext = new InitialContext(properties);
      System.out.println("Got context");

      //Get a references to the Bean
      Object ref = jndiContext.lookup("Adder");
      System.out.println("Got Refefence");

      //Get a reference from this to the Bean's Home interface
      AdderHome home = (AdderHome) PortableRemoteObject.narrow(ref, AdderHome.class);

      //Create an Adder object from the Home interface
      Adder adder = home.create();
      System.out.println("2 + 5 = " + adder.add (2, 5));
      }
      catch (Exception e)
      {
      System.out.println(e.toString());
      }
      }
      }


      =====================
      here's my ejb-jar and jboss
      =====================
      <?xml version="1.0" encoding="UTF-8"?>

      <!--
      <!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>
      My First EJB application
      <display-name>Adder Application</display-name>
      <enterprise-beans>

      <ejb-name>Adder</ejb-name>
      exemplo.ejb.AdderHome
      exemplo.ejb.Adder
      <ejb-class>exemplo.ejb.AdderBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>

      </enterprise-beans>
      </ejb-jar>
      -----------------------------------
      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">


      <enterprise-beans>

      <ejb-name>Adder</ejb-name>
      <jndi-name>Adder</jndi-name>

      </enterprise-beans>