![](/img/trans.png)
[英]Call an ejb entity class from an independent web application (netbeans)
[英]How to call remote EJB from standalone client
我將EJB部署在weblogic服務器上。 我想從獨立應用程序(瘦客戶端)訪問那些EJB。
好吧...我自己找到的。 :)
這是我用來從瘦客戶端連接到遠程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()
這對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.