如何从独立客户端调用远程EJB [英] How to call remote EJB from standalone client

查看:126
本文介绍了如何从独立客户端调用远程EJB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的EJB部署在weblogic服务器上。我想从独立应用程序(瘦客户端)访问这些EJB。

I have my EJB deployed on weblogic server. I want to access those EJB from standalone applications (a thin client).

推荐答案

好的......我自己找到了。 :)

Ok... I found it myself. :)

这是我用来从瘦客户端连接到远程EJB的代码。

Here is code that I used to connect to Remote EJB from thin client.

 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()

这对我有用。

这篇关于如何从独立客户端调用远程EJB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆