8

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

0

1 Answer 1

20

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.

Sign up to request clarification or add additional context in comments.

4 Comments

You should accept your own answer if this is what worked for you.
If you use a weblogic.jndi.WLInitialContextFactoryit means that you must call your EJB only from a client grabbing some weblogic libraries, wich is probably not that thin.
you should close the initial context in a finally block
The above code i'm running from command line java program (public static void main), i'm getting below error. Please suggest. Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory] Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.