Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Look up Remote EJB  RSS feed

 
Stu Higgs
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am just getting started with EJB and I have my EJB running in a separate JVM from the Web Application client. Is the IIOP_URL_STRING correct or is there some other way it is supposed to be done? This is the first time I am trying to access an EJB running in a separate JVM. Here is how I look up the EJB:

static final String CONTEXT_NAME = "java.naming.factory.initial";
static final String IIOP_STRING = "com.sun.jndi.cosnaming.CNCtxFactory";
static final String URL_NAME = "java.naming.provider.url";
static final String IIOP_URL_STRING = "iiop://192.168.1.3:8002";

Hashtable env = new Hashtable();
env.put(CONTEXT_NAME, IIOP_STRING);
env.put(URL_NAME, IIOP_URL_STRING);
Context ctx = new InitialContext(env);

Object h = ctx.lookup("HelloWorldEJB");
home = (HelloWorldHome)PortableRemoteObject.narrow(h, HelloWorldHome.class);

Thanks!
 
Stu Higgs
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the answer to my question, although I am still not sure if the way I accessed the InitialContext in the example above is a generic way of doing it via IIOP, but the solution to the question turned out to be specific to WebLogic. I'm still interested in reading more experienced developers input on the above code if there is anything to elaborate about?

Here is the solution to my original question in case anyone comes along in the future with a similar question:

Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://192.168.1.3:8002");
Context ctx = new InitialContext(ht);
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!