cancel
Showing results for 
Search instead for 
Did you mean: 

JNDI Lookup string incase of JavaProxy client call

Former Member
0 Kudos

Hello All,

I successfully tried to connect to XI from Java Proxy.basically I tried the example given by Sudhir.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/java proxies and sap xi - the inside story,%20Part%20II.pdf

But I faced lot of problems regarding the lookup string for the same. The one string mentioned in his PDF java:comp/env/ejb/BeanName never worked for me.Finally I searched into our JNDI for sap.com and finally I got the string sap.com/AppName/BeanName. I tried with this string but was giving ClassCastExceptions and NullPointerExceptions. Then I referred to the documenation of the SAP for local ejbs (the example was creating the instance of local ejb) which says the path starts with localejbs (localejbs/sap.com/appname/beanname) and finally it worked for us.

There we have InvokeProxy class which is encapsulated in the same EAR file. Now I am having wrapper another EJB which calls the Proxy EJB with the same lookup string but still it gives ClassCast Exception. I have written small application to call this wrapper EJB in which the connection was successful but gave error while calling ProxyEJB.

Does anyone know the standard JNDI lookup string (for SAP-WAS) or any method to find out the same which will give reference of our Home interface.

Thanks in advance.

Regards

Rajeev

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

You have to distinguish between calls from outside to the J2EE and calls between EJBs.

When you call from outside, you address the EJBs running on the server by the JNDI name.

When an EJB (or a servlet/JSP) calls another EJB, then you have to assign a reference. In this reference, you define the name, you want to use in your program. It need not be the same as the JNDI name, as the reference in the ejb.xml or web.xml points to the called EJB.

When you create an EJB as a wrapper to the Java Proxy Beans, I recommend to combine the code and call the Java Proxy methods directly from the wrapper Bean.

Hope that helps,

Stefan

Former Member
0 Kudos

Stefan,

Thanks for the reply. I added the reference to other EJB in the calling EJB's ejb-xml.jar with proper name.But when I tried to lookup on that name then again it gives NamingException

ctx = new InitialContext();

Object obj = ctx.lookup("ref_name");

gives NamingException.

Regards

Rajeev

stefan_grube
Active Contributor
0 Kudos

It has to be:

ctx.lookup("java:comp/env/ejb/ref_name");

Regards

Stefan