title: Remote EJB3 access from Spring
body: <p>I have 2 applications - one EAR containing EJB3.0 and other its Spring client. Both deployed on same Websphere app server 7 instance i.e. same JVM. </p>
  
  <p>Here are couple of client parts:</p>
  
  <p>applicationContext.xml:</p>
  
  <pre><code>&lt;bean id="ruleService" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean"&gt;
      &lt;property name="jndiName" value="com.ecrd.ruleservice.Customer_Management_Service_JavaBusiness"/&gt;
      &lt;property name="businessInterface" value="com.ecrd.ruleservice.Customer_Management_Service_JavaBusiness"/&gt;
      &lt;property name="jndiEnvironment"&gt;  
            &lt;props&gt;  
               &lt;prop key="java.naming.factory.initial"&gt;com.ibm.websphere.naming.WsnInitialContextFactory&lt;/prop&gt;  
               &lt;prop key="java.naming.provider.url"&gt;corbaloc:iiop:localhost:2809&lt;/prop&gt;  
               &lt;/props&gt;  
          &lt;/property&gt;  
  &lt;/bean&gt;
  </code></pre>
  
  <p>Client code snippet:</p>
  
  <pre><code>ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
  Customer_Management_Service_JavaBusiness ruleService 
                      = (Customer_Management_Service_JavaBusiness)ctx.getBean("ruleService");
  </code></pre>
  
  <p>This works fine. EJB access deployed in other application in same container, works.</p>
  
  <p><strong>But it does not work if I move that client to other machine in same network</strong> and just change provider URL and give remote server IP instead of localhost. JNDI lookup problem occurs</p>
  
  <p>Exact Error:
  Error 500: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ruleService' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Context: CFSDDVM2399Node01Cell/nodes/CFSDDVM2399Node01/servers/server1, name: com.ecrd.ruleservice.Customer_Management_Service_JavaBusiness: First component in name com.ecrd.ruleservice.Customer_Management_Service_JavaBusiness not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0] </p>
  
  <p>I can't figure out what changes (and where) are required to connect to EJB hosted in different server JVM. Any help or suggestion are welcome.</p>