1 Reply Latest reply on Feb 12, 2003 11:12 AM by mschoning

    Initial Context problem

    jayy

      Hi,

      I'm having trouble accessing an EJB from an applet. My code looks pretty much like the example given at http://www.jboss.org/online-manual/HTML/ch11s21.html only it doesn't work. In the code I have:

      Properties p = new Properties();
      p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      String myServer = this.getCodeBase().getHost();
      p.setProperty(Context.PROVIDER_URL, "jnp://" + myServer + ":8520" ) ;
      InitialContext lContext = new InitialContext(p);

      After which I use the context to look up a session been, but when it trys to create the InitialContext I get the following error (followed by a stack trace):

      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory. Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory

      So it looks as though the Applet can't find my initial context factory (org.jnp.interfaces.NamingContextFactory), however, it is definately in the class path... I've even created an instance of it before the code above executed & it didn't have any problem creating it, the problem is just when the Initial context trys to use class loader to load it.

      Does anyone know where/why I'm going wrong & how to fix/get around it... or even if you have some other ideas I can try (I'm at a loss & ready to try anything). Thanks in advance for your help.

      Jay.

        • 1. Re: Initial Context problem
          mschoning

          This is how I do and it works for me:

          Hashtable props = new Hashtable();
          props.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

          props.put(InitialContext.PROVIDER_URL, "jnp://localhost:1099");

          initialContext = new InitialContext(props);

          Also I run in the 'all' configuration of JBoss

          good luck, Michael
          good luck Michael