我正在使用 WAS 服务器,我编写了一个 java 客户端,通过业务接口调用一个 EJB,如下所示:
Hashtable<String, String> envJNDIProperties = new Hashtable<String, String>();
envJNDIProperties.put("javax.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
envJNDIProperties.put("java.naming.provider.url", "iiop://indmtx981:24121");
envJNDIProperties.put("java.naming.security.principal", myTicket);
envJNDIProperties.put("java.naming.security.credentials", "NA");
envJNDIProperties.put("org.omg.CORBA.ORBClass", "com.ibm.CORBA.iiop.ORB");
InitialContext initialCtx = new InitialContext(envJNDIProperties);
Object ejbObject = null;
/*
* Giving me error in following line
*/
SearchServicesRemoteBusiness remoteBusiness = (SearchServicesRemoteBusiness) initialCtx.lookup("amdocs-RM-Billing/CM-L1/SearchServicesBean!amdocs.csm3g.sessions.views.business.remote.SearchServicesRemoteBusiness");
System.out.println("Got referencve for: "+ ejbObject.getClass().getName());
// SearchServicesRemoteBusiness remoteBusiness = (SearchServicesRemoteBusiness) PortableRemoteObject.narrow(ejbObject,amdocs.csm3g.sessions.views.business.remote.SearchServicesRemoteBusiness.class);
AccountIdInfo accountId = new AccountIdInfo();
remoteBusiness.searchAccountById(accountId);
错误:
java.lang.ClassCastException: org.omg.stub.java.rmi._Remote_Stub 不能在 EJBStandaloneClient.main(EJBStandaloneClient.java:27) 中转换为 .SearchServicesRemoteBusiness
我尝试过的:我使用 createEJBStubs.sh 为这个远程业务接口创建存根,并在运行时将此存根放在客户端类路径中,但错误仍然存在。欢迎任何建议。