从独立客户端查找远程EJB时,AssertionError“Context可能不为null”

问题描述 投票:1回答:1

我正在运行WebLogic 12c,并将多个bean作为EAR文件的一部分进行部署。我还有一个独立的客户端,我从Eclipse运行,试图访问远程EJB。我正在使用注释,因此使用EJB 3.1中的全局可移植JNDI名称(例如java:global / ifactory / ifactory-ejb-4.0.0 / BomServiceBean!com.icumed.ifactory3.service.BomServiceRemote)。

但是,当远程客户端尝试调用EBJ时,我得到以下异常:

11:45:03,400 ERROR [com.icumed.ifactory3.service.RemoteServiceFactoryImpl] [getService('java:global/ifactory/ifactory-ejb-4.0.0/BomServiceBean!com.icumed.ifactory3.service.BomServiceRemote')] Context may not be null
java.lang.AssertionError: Context may not be null
    at weblogic.j2eeclient.SimpleContext.checkForNameUnderRemoteNode(SimpleContext.java:103)
    at weblogic.j2eeclient.SimpleContext.internalLookup(SimpleContext.java:68)
    at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:39)
    at weblogic.jndi.SimpleContext.lookup(SimpleContext.java:86)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at com.icumed.ifactory3.service.RemoteServiceFactoryImpl.getService(RemoteServiceFactoryImpl.java:323)

bean看起来像这样:

@Stateless
public class BomServiceBean extends AbstractSessionBean implements LocalBomService, BomServiceRemote
{
  ...
}

更多信息:当wlthint3client.jar和wlclient.jar在类路径上时,会发生此错误。

当只有wlthint3client.jar在类路径上时,例外是

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
    at weblogic.rmi.internal.StubInfo.getEnvQueriedJNDITimeout(StubInfo.java:256)
    at weblogic.rmi.internal.StubInfo.setEnvQueriedJNDITimeout(StubInfo.java:242)
    at weblogic.rmi.internal.StubInfo.readObject(StubInfo.java:238)

当wlclient.jar和wlthint3client.jar在类路径上时,WebLogic会打印此日志消息:

The connection attempt was rejected because the incoming protocol iiop is not enabled on channel Default[iiop][12]

我该如何纠正?

java jndi weblogic12c ejb-3.1
1个回答
0
投票

首先,确保在类路径中只有wlthint3client.jar,而不是wlclient.jar。这将摆脱AssertionError,只留下ClassCastException。

其次,ClassCastException问题在wlthint3client.jar(StubInfo.java)的代码中。如果在jndi.properties文件中指定它们,则以下两个属性无法从String正确转换为Long。

Long o = (Long)props.get("weblogic.jndi.responseReadTimeout");

if (o == null) {
  o = (Long)props.get("weblogic.rmi.clientTimeout");
}

如果需要设置这些属性,则必须在代码中创建Hashtable并将其传递给InitialContext。

Hashtable<String, Object> env = new Hashtable<String, Object>();

env.put("weblogic.jndi.responseReadTimeout", 15000L);
env.put("weblogic.rmi.clientTimeout", 15000L);
© www.soinside.com 2019 - 2024. All rights reserved.