1 Reply Latest reply on Apr 17, 2002 5:41 PM by admiyo

    newbie wants JNDI InitialContext

    nlessmann


      Hi!

      I just can't get it working... When I try to look up the InitialContext w/ the following code, I get a NamingException (thrown because of a ConnectException) saying connection refused. Can someone please provide w/ some hello-world style code (or tell me where to get it)?

      Hashtable JNDIParm = new java.util.Hashtable();
      JNDIParm.put(Context.URL_PKG_PREFIXES,
      "org.jboss.naming");
      JNDIParm.put(Context.PROVIDER_URL, "localhost:1099");
      JNDIParm.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      Context c = new InitialContext(JNDIParm);
      Object ref = c.lookup("ejb/myBean");

      Thanks for any help,
      Nils


        • 1. Re: newbie wants JNDI InitialContext

          Do you have JBoss running?


          This is my Basic code:

          Properties props = new Properties();

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

          System.getProperties().putAll(props);


          InitialContext jndiContext = new InitialContext();
          Object ref = jndiContext.lookup("Agency");
          agencyHome = (AgencyHome) PortableRemoteObject.narrow (ref, AgencyHome.class);