weblogic服务器上非ejb类怎么调用ejb

楼上说的是客户端调用
2025-03-24 19:42:48
推荐回答(1个)
回答1:

Hashtable props = new Hashtable();
props.putprops.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(props);
Object object = ctx.lookup("CustomerService/remote");

ICustomerService service = (ICustomerService) PortableRemoteObject.narrow(object, ICustomerService.class);

其中"CustomerService/remote"为ejb部署后对应的jndi,ICustomerService 为远程调用接口类。