Hi,
Please help me with some suggestions
I'm using Sun one ( version7 ) app server, This application has some samples and I'm trying to execute those samples ( Stateless session bean simple bean example )
I'm able to access the
EJB through
servlet ( GreeterServlet (
http://127.0.0.1/helloworld/GreeterServlet )
I'm trying to access the same EJB through a standalone
java class through JNDI lookup
I'm getting the following error :0
Greeter bean home not found - Is bean registered with JNDI?: javax.naming.NoInitialContextException: 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
Here is my Javaclass code, Interestingly this is the same code that is there in the servlet, I'm missing the some where with the JNDI property, this is available in the servlet container env. but not in my standalone javaclass
Java main method code:
Greeter myGreeterBean;
GreeterHome myGreeterHome;
Greeter myGreeterRemote;
InitialContext initContext = null;
try {
initContext = new javax.naming.InitialContext();
}
catch (Exception e) {
System.out.println("Exception creating InitialContext: " + e.toString());
return;
}
try {
System.out.println("Looking up greeter bean home interface");
String JNDIName = "java:comp/env/ejb/greeter"; System.out.println("Looking up: " + JNDIName);
Object objref = initContext.lookup(JNDIName);
myGreeterHome = (GreeterHome)PortableRemoteObject.narrow(objref, GreeterHome.class);
}
catch(Exception e) {
System.out.println("Greeter bean home not found - " +"Is bean registered with JNDI?: " + e.toString());
return;
}
Thanks,
AVNUS