• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

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?
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic