cancel
Showing results for 
Search instead for 
Did you mean: 

Too dumb for JNDI

Former Member
0 Kudos
144

Hi there,

apparently I'm too dumb to use JNDI, and I would really appreciate if someone could help me out:

I have a WebDynpro that will be deployed to WAS instance A and that has to lookup an EJB that will be deployed to WAS instance B. A and B do not form a cluster.

I initialize my context like this:

prop.put(InitialContext.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");
prop.put(InitialContext.PROVIDER_URL,remoteHost);

where remoteHost is a String variable containing the host name and port ("blablabla:50004").

Then I try to lookup a bean like this:

Object remoteReference = ctx.lookup("<vendor-prefix>/<application>/<bean>");

The lookup fails with a NamingException, telling me that there are no elements under <vendor-prefix>.

The JNDI tree of WAS B does contain the appropriate entry for the bean, and I have not problems looking it up if both applications reside on B.

What is it I'm missing here? Any hint appreciated!

Regards

Nils

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos
Former Member
0 Kudos

Dear Vijith,

unfortunately not; the problem is not that the lookup is done on the wrong node, but that it is not done at all.

By the way, I got the exception wrong; it's not a NamingException, but a NameNotFoundException.

Regards

Nils

Vlado
Advisor
Advisor
0 Kudos

Hi Nils,

Anyway, have you tried with the "force_remote" property and with specifying the security credentials?

> the problem is not that the lookup

> is done on the wrong node, but that it is not done at all.

Why do you think so? If the lookup operation throws an exception then it is done but fails because the object cannot be found on the local node.

> By the way, I got the exception wrong; it's not a

> NamingException, but a NameNotFoundException.

NameNotFoundException extends NamingException and "is thrown when a component of the name cannot be resolved because it is not bound."

Best regards,

Vladimir

Former Member
0 Kudos

check this blog

/people/helmut.tammen2/blog/2005/04/06/jndi-lookup-of-ejbs-that-reside-at-web-as

Vlado
Advisor
Advisor
0 Kudos

Dear Noufal,

Lookup from a standalone client is a different story. Moreover, there are a number of inaccuracies in that blog.

Best regards,

Vladimir

Former Member
0 Kudos

Dear Vladimir,

as to your posting this morning: by saying that the lookup is not done at all I merely meant to say that the link Vijith posted does not fit to my problem description.

As to your posting this afternoon: Yes, I did add "force_remote" and the credentials. And yes, it <i>is</i> a NamingException. Forget everything I said about the NameNotFoundException (seems I got puzzled by my own debugging attempts).

Actually I also got a NamingException when I tried the remote lookup from a "regular" J2EE component (servlet); it seems this is rather a security issue:

If I <i>don't</i> pass the credentials, the root exception is a

"P4BaseConnectionException: Incorrect client ID. The stub is not connected yet"

If I <i>do</i> pass the credentials, the root exception is a

"BaseLoginException: Cannot create new RemoteLoginContext instance"

Does that sound familiar to anyone? Do I have to tweak the configuration of the target WAS? Do I have to throw in any additional DCs?

Regards

Nils

Former Member
0 Kudos

Hi,

I tried working on your scenario..

Let me tell you what I did.

I created an ejb(say TestEjb) and deployed it on a server (say serverA) and created an application (say TestApp) and deployed it on a server (say serverB).

The JNDI name that I gave is <project name>/<some name>

The code for look up was as below

Hashtable ht=new Hashtable();

ht.put(Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");

ht.put(Context.PROVIDER_URL,"serverA:50004");

Context ctx=new InitialContext(ht);

TestEjbHome myHome = (TestEjbHome)ctx.lookup("<package name>/<some name>");

TestEjb local=myHome.create();

now local.add(a,b); add() is a method in my TestEjb its working..

Regards

Noufal

Former Member
0 Kudos

Were you able to solve this issue?

I'm having the same Problem.

Siva Anne