Hi,
I am trying to run a
java class from a dos command. This class tries to instantiate
EJB session beans.
I can run this class from calling a
servlet from a
JSP page but need to run the same process from a dos command also so I have created a new class to carry out the same functions as my servlet.
When I try to creat my home object for my session beans from my new class I cannot seem to do so. It breaks down in the following method.
public static Object getEJBHome(
String ejbName) {
// lookup the Session bean home object using JNDI
Object homeObj = null;
try {
javax.naming.Context jndiContext = new javax.naming.InitialContext();
if(jndiContext == null) {
System.out.println("jndiContext == null");
}else{
System.out.println("jndiContext != null");
}
System.out.println("About to retrieve homeObj");
System.out.println("ejbName = " + ejbName);
homeObj = jndiContext.lookup("java:comp/env/ejb/" + ejbName);
if(homeObj == null) {
System.out.println("homeObj == null");
}else{
System.out.println("homeObj != null");
}
} catch (javax.naming.NamingException ne) {
System.out.println("NamingException ne = " + ne.toString());
//throw new ServletException(ne);
}
return homeObj;
}
I receive a NamingException as follows:
NamingException ne = javax.naming.NoInitialContextException: Need to specify
class name in environment or system property, or as an
applet parameter, or in
application resource file: java.naming.factory.initial
I do not receive this exception when i run similiar operations from jsp and servlets. Does anyone know how I can run my dos command without getting this problem?