I have two local websphere 7 application servers (two profiles) on the same machine. Just a default installation with no custom configuration. One exposes a service deployed as an EJB3 session bean with ejb/edu/test/EjbFacade JNDI name.
I wrote a simple JUnit integration test which calls a method remotely:
@Test
public void testCall() throws Exception {
Hashtable props = new Hashtable();
props.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2811");
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
props.put("org.omg.CORBA.ORBClass", "com.ibm.CORBA.iiop.ORB");
InitialContext initialContext = new InitialContext(props);
Object obj = initialContext.lookup("cell/nodes/myNode03/servers/server1/ejb/edu/test/EjbFacade");
EjbFacade facade = (EjbFacade) PortableRemoteObject.narrow(obj, EjbFacade.class);
facade.doSomething();
}
This works fine!
Then I have a web application with an EJB reference:
ibm-web-bnd.xmi
<ejbRefBindings xmi:id="EjbRefBinding_1386431681401" jndiName="ejb/edu/test/EjbFacade">
<bindingEjbRef href="WEB-INF/web.xml#EjbRefBinding_EjbFacade"/>
</ejbRefBindings>
web.xml
<ejb-ref id="EjbRefBinding_EjbFacade">
<ejb-ref-name>ejb/edu/test/EjbFacade</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home/>
<remote>edu.test.EjbFacade</remote>
</ejb-ref>
And I am doing the same EJB call from a servlet using local JNDI name: java:comp/env/ejb/edu/test/EjbFacade mapped to corbaloc:iiop:localhost:2811/cell/nodes/myNode03/servers/server1/ejb/edu/test/EjbFacade in websphere admin console.
The call fails with exception:
Caused by: javax.naming.ServiceUnavailableException: A communication failure
occurred while attempting to obtain an initial context with the provider URL:
"corbaloc:iiop:localhost:2811/cell/nodes/myNode03/servers/server1/ejb/edu/test/EjbFacade".
Make sure that any bootstrap address information in the URL is correct and that the target
name server is running. A bootstrap address with no port specification defaults to port 2809.
Possible causes other than an incorrect bootstrap address or unavailable name server
include the network environment and workstation network configuration.
[Root exception is org.omg.CORBA.OBJECT_NOT_EXIST: LocateRequest 6 received
LocateReply.UNKNOWN_OBJECT vmcid: IBM minor code: C01 completed: No]
What JNDI name should I configure in the WAS console? Why the same code is working under JUnit but fails from the servlet?