title: @ejb injection works, jndi lookup doesn't in Glassfish 3
body: <p>I have a stateless ejb.</p>
  
  <pre><code>@Remote
  public interface MyService {
     ...
  }
  
  impl
  
  @Stateless
  public class MyServiceImpl implements MyService {
    ...
  }
  </code></pre>
  
  <p>I have another bean which is trying to use MyService, that will be exposed via JMX.</p>
  
  <pre><code>@MXBean
  public interface MyJMXBean {
     ...
  }
  
  @Singleton
  @Startup
  public class MyJMXBeanImpl implements MyJMXBean {
     @EJB
     MyService service; // this works
  
     @PostConstruct
     private void init() { ... }
  
     @PreDestroy
     private void cleanup() { ... }
  
     // this doesn't
     private MyService doLookup() {
        InitialContext ctx = new InitialContext();
        return (MyService) ctx.lookup(MyService.class.getName());
     }
  }
  </code></pre>
  
  <p>I would like to be able to do a jndi lookup of MyService so I don't have the deployment dependency on the ear that provides MyService.  The ears providing MyService and MyJMXBean are different, but deployed to the same container.  The exception I'm getting is:</p>
  
  <pre><code>Caused by: javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:542) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
          at javax.naming.InitialContext.lookup(InitialContext.java:411) ~[na:1.7.0_15]
          at javax.naming.InitialContext.lookup(InitialContext.java:411) ~[na:1.7.0_15]
          at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:71) ~[ejb-container.jar:3.1.2.1-SNAPSHOT]
          at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:580) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
          ... 38 common frames omitted
  Caused by: org.omg.CORBA.INITIALIZE: can't instantiate default ORB implementation com.sun.corba.ee.impl.orb.ORBImpl
          at org.omg.CORBA.ORB.create_impl(ORB.java:314) ~[na:1.7.0_15]
          at org.omg.CORBA.ORB.init(ORB.java:353) ~[na:1.7.0_15]
          at com.sun.jndi.toolkit.corba.CorbaUtils.getOrb(CorbaUtils.java:203) ~[na:1.7.0_15]
          at com.sun.jndi.cosnaming.CNCtx.getDefaultOrb(CNCtx.java:72) ~[na:1.7.0_15]
          at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(CNCtx.java:234) ~[na:1.7.0_15]
          at com.sun.jndi.cosnaming.CNCtx.&lt;init&gt;(CNCtx.java:105) ~[na:1.7.0_15]
          at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(CNCtxFactory.java:49) ~[na:1.7.0_15]
          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) ~[na:1.7.0_15]
          at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307) ~[na:1.7.0_15]
          at javax.naming.InitialContext.init(InitialContext.java:242) ~[na:1.7.0_15]
          at javax.naming.InitialContext.&lt;init&gt;(InitialContext.java:216) ~[na:1.7.0_15]
          at com.sun.enterprise.naming.util.IIOPObjectFactory.getObjectInstance(IIOPObjectFactory.java:73) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
          at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:580) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
          at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514) ~[glassfish-naming.jar:3.1.2.1-SNAPSHOT]
          ... 44 common frames omitted
  Caused by: java.lang.ClassNotFoundException: com.sun.corba.ee.impl.orb.ORBImpl
          at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_15]
          at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_15]
          at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_15]
          at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_15]
          at java.lang.ClassLoader.loadClass(ClassLoader.java:423) ~[na:1.7.0_15]
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.7.0_15]
          at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ~[na:1.7.0_15]
          at java.lang.Class.forName0(Native Method) ~[na:1.7.0_15]
          at java.lang.Class.forName(Class.java:266) ~[na:1.7.0_15]
          at org.omg.CORBA.ORB.create_impl(ORB.java:312) ~[na:1.7.0_15]
          ... 57 common frames omitted
  </code></pre>
  
  <p>I'm not quite sure how to resolve the ClassNotFoundException, as everything is running inside Glassfish.</p>