title: Cannot instantiate InitialContext with JBoss server
body: <p>I'm trying to create a <code>InitialContext</code> so I could ask the JNDI for some enterprise java beans.
  The JBoss is running fine, but when I run the java code I get an exception.</p>
  
  <p>I'm running JBoss 7.1</p>
  
  <p>Here is my code: </p>
  
  <pre><code>public class Test {
  
      public static void main(String[] args){
          InitialContext ctx=getInitialContext();
          Object ref=null;
          try {
              ref = ctx.lookup("ParamEJB/remote");
          } catch (NamingException e) {
              System.out.println("Lookup Failed");
              e.printStackTrace();
          }
          Param stub=(Param)PortableRemoteObject.narrow(ref, Param.class);
          int times=stub.getTimes();
          for(int i=0;i&lt;times;i++)
              System.out.println(stub.getMessage());
      }
  
      public static InitialContext getInitialContext(){
          Hashtable&lt;String,String&gt; h=new Hashtable&lt;String,String&gt;();
          h.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
          h.put("java.naming.provider.url","localhost");
          try {
              return new InitialContext(h);
          } catch (NamingException e) {
              System.out.println("Cannot generate InitialContext");
              e.printStackTrace();
          }
          return null;
      }
      }
  </code></pre>
  
  <p>And after i start my JBoss server, I try to run the java code and I get this exception:</p>
  
  <pre><code>javax.naming.NoInitialContextException: Cannot instantiate class:     org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException:     org.jnp.interfaces.NamingContextFactory]
  at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
  at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
  at javax.naming.InitialContext.init(Unknown Source)
  at javax.naming.InitialContext.&lt;init&gt;(Unknown Source)
  at client.Test.getInitialContext(Test.java:32)
  at client.Test.main(Test.java:13)
  Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  </code></pre>
  
  <p>What might be the problem?</p>