title: Cannot create an initial context from a Swing client
body: <p>Please see the code below:</p>
  
  <pre><code>try {
              //InitialContext ic = new InitialContext();
              Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY,  
               "com.sun.enterprise.naming.SerialInitContextFactory");
              Context ctx = new InitialContext(env);      
  
              MySessionRemote hb = (MySessionRemote) ctx.lookup("MySessionRemote");
              System.out.println(hb.getResult());
          } catch (NamingException ex) {
              ex.printStackTrace();
          }
  </code></pre>
  
  <p>The error I get from a Swing app is<code>:(javax.naming.NoInitialContextException) javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]</code> </p>
  
  <p>I have not worked with Java for a while so this could be quite straightforward.  </p>
  
  <p><strong>Update</strong></p>
  
  <p>I am using version 4.1 of Glassfish.  I have added references to the following jars inside the NetBeans project:</p>
  
  <pre><code>appserv-rt.jar
  gf-client.jar
  javaee.jar
  </code></pre>
  
  <p>I can now get an InitialContext.  However, I cannot lookup the bean i.e. this line fails:</p>
  
  <pre><code>MySessionRemote hb = (MySessionRemote) ctx.lookup("ejb.MySessionRemote");
  </code></pre>
  
  <p>The exception is a <code>NamingException</code> i.e. <code>Lookup Failed</code>.  I believe the name of the bean may be wrong. Here is the bean:</p>
  
  <p>package ejb;</p>
  
  <pre><code>import javax.annotation.Resource;
  import javax.ejb.Remote;
  @Resource(name = "MySessionRemote")
  @Remote
  public interface MySessionRemote {
      public String getResult();
  }
  </code></pre>
  
  <p>What should the name of the bean be?</p>