3 Replies Latest reply on Jul 23, 2007 9:55 AM by wayne baylor

    Fail to try first example in "Enterprise JavaBean 3.0"

    Ilan Amar Newbie

      Hi,

      I am trying the first example in "Enterprise JavaBeans 3.0" / chapter 4 and for some reason I am keep getting the following error message: "TravelAgentBean not bound".


      package titan.Clients;

      import titan.travelagent.TravelAgentRemote;
      import titan.domain.Cabin;

      import javax.naming.InitialContext;
      import javax.naming.Context;
      import javax.naming.NamingException;
      import java.util.Properties;
      import javax.rmi.PortableRemoteObject;

      public class Clients {
      public static void main(String[] args) {
      try{
      Context jndiContext = getInitialContext();
      Object ref = jndiContext.lookup("TravelAgentBean/remote");
      TravelAgentRemote dao = (TravelAgentRemote) PortableRemoteObject.narrow(ref, TravelAgentRemote.class);

      Cabin cabin_1 = new Cabin();
      cabin_1.setId(1);
      cabin_1.setName("Master Suite");
      cabin_1.setDeckLevel(1);
      cabin_1.setShipId(1);
      cabin_1.setBedCount(3);

      dao.createCabin(cabin_1);

      Cabin cabin_2 = dao.findCabin(1);
      System.out.println(cabin_2.getName());
      System.out.println(cabin_2.getDeckLevel());
      System.out.println(cabin_2.getShipId());
      System.out.println(cabin_2.getBedCount());
      }
      catch(NamingException ne) {ne.printStackTrace();}
      }

      public static Context getInitialContext() throws NamingException {
      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
      p.put(Context.PROVIDER_URL,"jnp://localhost:1099");
      return new InitialContext(p);
      }
      }


      Also, I would like to mention that when I run JBoss I see the following error message: "No ClassLoaders for titan.travelagent.TravelAgentBean"

      Please Helpppppp....