cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

JNDI InitialContext Error

Former Member
0 Likes
2,268

Hello Experts,

I have a little problem with my Java programm:

Test remote = null;

* try {*

// Create a new intial context, which loads from jndi.properties file.

* *

* Context ctx = new InitialContext();*

* System.out.println("Context:" + ctx);*

// Look up the home interface using the JNDI name.

// This JNDI lookup returns a reference to an EJBHome instance.

* TestHome home = (TestHome) ctx.lookup("sap.com/TestWorldEar/TestBean");*

* System.out.println("TestHome:" + home);*

// Create a session object.

* remote = home.create();*

* System.out.println("Remote:" + remote);*

// Invoke the remote EJB methods, test and debug.

* System.out.println("Result:" + remote.getWert());*

* } catch (Exception e) {*

* System.out.println("Exception: " + e.getLocalizedMessage());*

* }*

I always get the following error and I don't know how to solve the problem.

Exception: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

I hope anybody of you can help me solving this problem.

Additional information:

The Java program is running on a XI (Netweaver 7.0).

I want to get information from a deployed EJB. The Bean still works.

Thank you for your answers in advance!!!

Greetings, Alexander

View Entire Topic
siddharth_jain
Active Contributor
0 Likes

Hi,

Updated:

i think You are trying to lookup the Remote home interface using the procedure of Local home Interface lookup,For local home interface lookup you have to prefix localejbs before the default Jndi name of the Bean.

Check the default name under Visual Admin.

And rest of the lookup code is fine.

But in case of Remote home lookup the lookup syntex will be different:

<BeanHome Home = (<Bean>Home) javax.rmi.PortableRemoteObject.narrow(ctx.lookup(<Default Jndi Name without localejbs prefix>),<Bean>Home.class);

Check the Following link Also See the last reply.

Regards,

Siddharth

Edited by: Siddharth Jain on Sep 4, 2008 6:36 AM