• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Initial Context for EJB - Problem executing from Dos command

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic