[英]How to call remote EJB from standalone client
I have my EJB deployed on weblogic server. 我将EJB部署在weblogic服务器上。 I want to access those EJB from standalone applications (a thin client).
我想从独立应用程序(瘦客户端)访问那些EJB。
Ok... I found it myself. 好吧...我自己找到的。 :)
:)
Here is code that I used to connect to Remote EJB from thin client. 这是我用来从瘦客户端连接到远程EJB的代码。
Hashtable env = new Hashtable(5);
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
//Assuming weblogic server is running on localhost at port 7001
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ic = new InitialContext(env);
//obtain a reference to the home or local home interface
FooHome fooHome = (FooHome)ic.lookup("MyBeans/FooHome");
//Get a reference to an object that implements the beans remote (component) interface
Foo foo = fooHome.create();
//call the service exposed by the bean
foo.shoutFoo()
And it worked me. 这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.