title: EJB Jndi look up in Glassfish server only in Java Web start
body: <p>I am trying to connect to the ejb service in glassfish server through Java Web start. 
  I am getting the following error while getting the initial context.  I have also added the code snippet for getting the initial context. </p>
  
  <p>One interesting is when I run the program as a simple java program outside of java web start in a netbeans IDE, it is working fine. </p>
  
  <p>I added all the relevant jar files from the glassfish modules folder into the java web start. </p>
  
  <pre><code>java.lang.NullPointerException
      at com.sun.enterprise.naming.impl.SerialContext.&lt;init&gt;(SerialContext.java:275)
      at com.sun.enterprise.naming.impl.SerialContext.&lt;init&gt;(SerialContext.java:334)
      at com.sun.enterprise.naming.impl.SerialInitContextFactory.createInitialContext(SerialInitContextFactory.java:358)
      at com.sun.enterprise.naming.impl.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:353)
      at com.sun.enterprise.naming.SerialInitContextFactory.getInitialContext(SerialInitContextFactory.java:69)
      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 gov.ca.lc.util.ServiceLocator.getInitialContext(ServiceLocator.java:140)
      at gov.ca.lc.util.ServiceLocator.getVotesEJB(ServiceLocator.java:103)
      at gov.ca.lc.scenemanagement.AbstractVotingScene.getCommitteeList(AbstractVotingScene.java:143)
      at gov.ca.lc.scenemanagement.AbstractVotingScene.&lt;init&gt;(AbstractVotingScene.java:65)
      at gov.ca.lc.scenes.MenuScene.&lt;init&gt;(MenuScene.java:56)
      at gov.ca.lc.menu.StartVoting.startUp(StartVoting.java:47)
      at org.mt4j.MTApplication.setup(MTApplication.java:328)
      at processing.core.PApplet.handleDraw(PApplet.java:1580)
      at processing.core.PApplet.run(PApplet.java:1502)
      at java.lang.Thread.run(Unknown Source)
  Exception in thread "Animation Thread" java.lang.NullPointerException
      at gov.ca.lc.scenemanagement.AbstractVotingScene.getCommitteeList(AbstractVotingScene.java:143)
      at gov.ca.lc.scenemanagement.AbstractVotingScene.&lt;init&gt;(AbstractVotingScene.java:65)
      at gov.ca.lc.scenes.MenuScene.&lt;init&gt;(MenuScene.java:56)
      at gov.ca.lc.menu.StartVoting.startUp(StartVoting.java:47)
      at org.mt4j.MTApplication.setup(MTApplication.java:328)
      at processing.core.PApplet.handleDraw(PApplet.java:1580)
      at processing.core.PApplet.run(PApplet.java:1502)
      at java.lang.Thread.run(Unknown Source)
  
  
  Following is my code to get the initial context
  
      private static InitialContext getInitialContext()
              throws NamingException {
              Properties props = null;
              try{  
      //            props=new Properties();   
      //            props.load(new FileInputStream(new File("jndi.properties")));
      //            System.out.println(props.get("java.naming.factory.initial"));
                   props=new Properties();   
  
  
      props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");  
          props.setProperty("java.naming.factory.url.pkgs ", "com.sun.enterprise.naming");//ur server ip  
          props.setProperty("java.naming.factory.state ", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");//ur server ip  
          props.setProperty("org.omg.CORBA.ORBInitialHost", "165.107.33.181");//ur server ip  
          props.setProperty("org.omg.CORBA.ORBInitialPort","3700"); //default is 3700  
  
  
              }catch(Exception ex){
                  ex.printStackTrace();
              }
              return new InitialContext(props);
          }
  </code></pre>