cancel
Showing results for 
Search instead for 
Did you mean: 

InitialContext lookup returns null

Former Member
0 Kudos

Hi,

I've been trying to lookup() MBeanServerConnection object from the JNDI but it returns Null. Initial context is ok.

What am I doing wrong?

Properties p = new Properties();

p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

p.setProperty(Context.PROVIDER_URL, serverUrl);

p.setProperty(Context.SECURITY_PRINCIPAL, username);

p.setProperty(Context.SECURITY_CREDENTIALS, password);

p.setProperty("force_remote", "true");

String name = "jmx";

Context ctx = new InitialContext(p);

MBeanServerConnection mbs = (MBeanServerConnection) ctx.lookup(name);// returns null

Best regards,

wojtek

Accepted Solutions (0)

Answers (1)

Answers (1)

anandvithal
Active Participant
0 Kudos

Hi,

I see that you are doing EJB lookup from SAP server... keep in mind that if the EJB version is 2.X or below...the looup method will return reference to the HomeInterface. From the HomeInterface object you have to call create() method to get new Bean object.

If its EJB version 3.X then lookup method will return reference to the RemoteInterface. From remote interface you can directly call the business method exposed in that remote interface.

Also verify if you are giving the JNDI name of the bean correctly in the lookup method. You can get it from you server http://<host>:<port>/ejbexplorer

Thanks,

Anand

Message was edited by: Anand V D

Former Member
0 Kudos

Hello Anand,

I'm using my own standalone Java application that connects from remote server. When I run ctx.list("") it shows that jmx object is of a type com.sap.engine.services.jndi.ServiceReferenceImpl but I cannot find any documentation to this Class.

anandvithal
Active Participant
0 Kudos


Hi,

For standalone java application you need to

1) Add the sap client jar to your java application. You can find it on your sap server in below folder /usr/sap/<SID>/<DB Instance>/j2ee/j2eeclient. Look for the jar file with name sap.com~tc~je~clientlib~impl.jar

2) InitialContext PROVIDER_URL should be in format "<sapserverhost>:<p4port>". You can find the P4 port of you sap system in tcode SMICM and click on services(shift+f1).

Hope it helps.

Thanks,

Anand

Former Member
0 Kudos

Thank you for your help.

I use exception.jar, logging.jar and sapj2eeclient.jar. These are all needed as far as I know. I'm running SAP NW Portal 7.01.

InitialContext connects alright, I can list all JNDI objects on the server. The problem is the lookup() method which returns Null, this is the part which I'm having problems with.