title: javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable
body: <p>I have small program which just creating intial context in unmanaged environment i.e. outside the container.I have been using Websphere 7.0.
  I have written following program to do the connection with application which is running on WAS 7 using corba url,</p>
  
  <pre><code>package snippet;
  
  import java.util.Hashtable;
  
  import javax.naming.Context;
  import javax.naming.InitialContext;
  
  public class test {
      public static void main(String[] args) {
          try {
              // create initial context
              Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY,
                      "com.ibm.websphere.naming.WsnInitialContextFactory");
              env
                      .put(Context.PROVIDER_URL,
                              "corbaloc:iiop:1.0@x1devapp63.dev.freightliner.com:2809/NameService");
  
              InitialContext ctx = new InitialContext(env);
  
              System.out.println(ctx);
          } catch (Exception ex) {
              ex.printStackTrace();
          }
  
      }
  } 
  </code></pre>
  
  <p>I have created runnable jar and executing using shell script given below,</p>
  
  <pre><code>#!/bin/sh
  
  WAS_ROOT_PATH=/application/WebSphere/AppServer
  SCHEDULER_JAR=/application/apps/JobScheduler/testJNDI.jar
  SCHEDULE_FILE=/application/apps/JobScheduler/schedule.xml
  . "$WAS_ROOT_PATH"/bin/setupCmdLine.sh
  CLASSPATH="$MQLIB":"$WAS_CLASSPATH"
  "$JAVA_HOME"/bin/java -classpath "$CLASSPATH" -jar "$SCHEDULER_JAR"
  </code></pre>
  
  <p>Ater running i have been facing below exception,</p>
  
  <pre><code>$ testJNDI.sh
  javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {java.naming.provider.url=corbaloc:iiop:1.0@x1devapp63.dev.freightliner.com:2809/NameService, java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory} [Root exception is java.lang.NullPointerException]
          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:243)
          at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:327)
          at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:357)
          at javax.naming.InitialContext.internalInit(InitialContext.java:295)
          at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:212)
          at snippet.test.main(test.java:19)
  Caused by: java.lang.NullPointerException
          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:235)
          ... 5 more
  $ 
  </code></pre>
  
  <p>I got stuck on above problem but i could not get why this is happening.</p>
  
  <p>Please do the needful to get out me from above problem.</p>