websphere远程ejb调用CORBA.OBJECT_NOT_EXIST LocateReply.UNKNOWN_OBJECT次要代码:C01

时间:2014-03-05 05:52:17

标签: java-ee ejb websphere

我在同一台计算机上有两个本地websphere 7应用程序服务器(两个配置文件)。只是没有自定义配置的默认安装。一个使用ejb / edu / test / EjbFacade JNDI名称公开部署为EJB3会话bean的服务。

我写了一个简单的JUnit集成测试,它远程调用一个方法:

@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();
}

这很好用!

然后我有一个带有EJB引用的Web应用程序:

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>

我正在使用本地JNDI名称从servlet执行相同的EJB调用: java:comp / env / ejb / edu / test / EjbFacade 映射到 corbaloc:iiop:localhost: websphere管理控制台中的2811 / cell / nodes / myNode03 / servers / server1 / ejb / edu / test / EjbFacade

调用失败,异常:

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]

我应该在WAS控制台中配置什么JNDI名称?为什么相同的代码在JUnit下工作但从servlet失败?

2 个答案:

答案 0 :(得分:0)

好的,设法让它发挥作用。

问题是websphere安装程序默认创建了两个具有相同名称的服务器:server1

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

并且WAS中有bug导致了这样的问题。重命名一个服务器修复了ejb调用。

答案 1 :(得分:0)

您需要uniqueServerName选项。请参阅信息中心中Application access problems主题的“在同一主机上运行的两台具有相同名称的服务器”部分。