0
votes

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?

2
Also checked websphere documentation: the error description is "Ensure that the remote object that is requested resides in the specified server and that the remote reference is up-to-date". Could anybody elaborate a bit what "the remote reference is up-to-date" means?ike3

2 Answers

0
votes

You need the uniqueServerName option. See the "Two servers with the same name running on the same host are being used to interoperate" section of the Application access problems topic in the InfoCenter.

0
votes

Ok, managed to make it working.

The problem was that websphere installer created by default two servers with the same name: server1

  • myNode01Cell/myNode01/server1
  • myNode02Cell/myNode02/server1

and there is a bug in WAS that caused such a problem. Renaming one server fixed the ejb call.