title: How to access an EJB from a JSF application on separate machines?
body: <p>I have an Enterprise Application with an EJB implementing a @Remote business interface that I would like to access from a JSF managed bean on a different machine.  They are both development machines with Netbeans 7 and Glassfish 3.1.  I believe the answer lies with CORBA, but I do not think I am doing it right.</p>
  
  <p>Is there a better option then CORBA for this?</p>
  
  <p>Here is where I found how to use corbaname:iiop <a href="http://download.oracle.com/docs/cd/E19798-01/821-1752/beanv/index.html" rel="nofollow">http://download.oracle.com/docs/cd/E19798-01/821-1752/beanv/index.html</a></p>
  
  <p>This is my EJB Interface:</p>
  
  <pre><code>package remote.ejb;
  
  import javax.ejb.Remote;
  
  @Remote
  public interface HelloRemote {
      public String getHello();
  }
  </code></pre>
  
  <p>Enterprise Application: RemoteEJBTest
  Java EE Module: RemoteEJBTest-ejb</p>
  
  <p>EJB:</p>
  
  <pre><code>package remote.ejb;
  
  import javax.ejb.EJB;
  import javax.ejb.Remote;
  import javax.ejb.Stateless;
  
  @Stateless
  public class HelloBean implements HelloRemote {
  
      @Override
      public String getHello() {
          return "Hello World!";
      }
  }
  </code></pre>
  
  <p>Web Application: RemoteWebTest</p>
  
  <pre><code>package hello.web;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.RequestScoped;
  import javax.naming.InitialContext;
  import javax.naming.NamingException;
  import javax.rmi.PortableRemoteObject;
  import remote.ejb.HelloRemote;
  
  @ManagedBean
  @RequestScoped
  public class Hello {
      private HelloRemote helloBean;
  
      private String hello;
  
      public Hello() throws NamingException {
  
          InitialContext ctx = new InitialContext();
  
          Object obj = ctx.lookup("corbaname:iiop:remote_ip:3700#RemoteEJBTest/RemoteEJBTest-egb/HelloBean");
          helloBean = (HelloRemote) PortableRemoteObject.narrow(obj,HelloRemote.class);
      }
  
      public String getHello(){
          return helloBean.getHello();
      }
  }
  </code></pre>
  
  <p>Here is the stack trace <a href="http://pastebin.com/PxNCKCg4" rel="nofollow">http://pastebin.com/PxNCKCg4</a></p>
  
  <p>relavent parts of stack trace:</p>
  
  <pre><code>com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: hello.web.Hello.
      at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:193)
      at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
  
  Caused by: javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
      at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
      at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:485)
  
  Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
      at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
      at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:251)
      at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:471)
  ... 59 more
  </code></pre>
  
  <p>What is the best way to split EJBs over multiple remote machines?</p>