Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call remote EJB from standalone client

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

like image 431
Swapnil Avatar asked Nov 16 '08 12:11

Swapnil


1 Answers

Ok... I found it myself. :)

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

And it worked me.

like image 51
Swapnil Avatar answered Sep 29 '22 10:09

Swapnil