Help me in resoving JNDI error

Hi All,

I am a proficient J2SE & JSP coder... but I am writing my first EJB. So I am a fresher in this case.

I am starting with a simple EJB with Sun application server. I have coded the programs as follows

Home interface:->

public interface SimpleSessionHome extends EJBHome

{

public SimpleSession create() throws CreateException,RemoteException;

}

Remote interface:

public interface SimpleSession extends EJBObject

{

public void printString(String str) throws RemoteException;

}

EJB class

public class SimpleSessionBean implements SessionBean

{

public SimpleSessionBean()

{}

public void printString(String str)

{

System.out.println(str);

}

- //standard ejb methods...

--

My client code is like this:

public class SimpleSessionClient

{

public static void main(String args[]) throws Exception

{

InitialContext jndi=new InitialContext();

Object ref=jndi.lookup("SimpleSessionBean");

SimpleSessionHome home=(ejb/SimpleSessionHome)PortableRemoteObject.narrow(ref,SimpleSessionHome.class);

SimpleSession ss=home.create();

ss.printString("Hello World");

}

}

while executing the program I am getting the NoInitialContextException

I am executing it with the command

java -Dorg.omg.CORBA.InitialHost=localhost

-Dorg.omg.CORBA.InitialPort=3700 firstEjbclient.SimpleSessionClient

I have put the files in firstEjb(for Home,remote & bean files) & firstEjbclient(for client prog) packages resp.

I think this may be a deployment error... as the program is not so huge..

Can somebody answer me?

Sorry for writing such a long entry....

[1846 byte] By [J2ee_learnera] at [2007-11-26 15:58:46]
# 1

Which version of the Java EE SDK are you using? Take a look at our EJB FAQ to see how

to write EJB clients :

https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html

Also take a look at the entires describing how global JNDI names are assigned to

Remote EJBs.

--ken

ksaksa at 2007-7-8 22:19:55 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Thanks Ken!

The links provided by you helped me in getting rid of the exception. Very good documentation is kept there.

]The problem got resolved by explicitely specifying the context.

Although I got rid of the exception, the output is not getting generated.

I have checked the descriptors.

I am using J2EE SDK 1.4 with Sun app server.

Regards,

j2ee_learner

J2ee_learnera at 2007-7-8 22:19:55 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...