【发布时间】:2010-09-22 13:42:46
【问题描述】:
我的 EJB 部署在 weblogic 服务器上。我想从独立应用程序(瘦客户端)访问这些 EJB。
【问题讨论】:
标签: web-applications jakarta-ee
我的 EJB 部署在 weblogic 服务器上。我想从独立应用程序(瘦客户端)访问这些 EJB。
【问题讨论】:
标签: web-applications jakarta-ee
好的...我自己找到了。 :)
这是我用来从瘦客户端连接到远程 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()
它对我有用。
【讨论】:
weblogic.jndi.WLInitialContextFactory这意味着你必须只从客户端调用你的EJB,获取一些weblogic库,这可能不是那么薄。