• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Reading environment entry from a custom tag ..

 
Greenhorn
Posts: 13
  • 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 read an environment entry from a simple tag. I am using Tomcat 3.2 and the code inside the tag is as follows, where "name" is the environmnt entry name, which i have put in the web.xml file.
try{
InitialContext context=new InitialContext();
Object obj=(Object)context.lookup("java:comp/env/"+name);
pageContext.setAttribute(name,obj,PageContext.PAGE_SCOPE);
}catch(javax.naming.NamingException ne){
throw new JspException(ne.getMessage());
}
When i call the jsp page which consists of the tag, i can see from Tomcat window that environment entry is set initially. but the jsp page, simply gives the exception :
"javax.servlet.ServletException: 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"
Anybody please help..
 
Author
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it looks like the initial context provider is not set - the initial context may not be available on your system. You may need to set the provider when you are starting you application or perhaps set the system variable in an on startup loaded servlet
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... and an easy way to do this is just to put a jndi.properties file in the classpath of your web application (e.g. in WEB-INF/classes).
Simon
reply
    Bookmark Topic Watch Topic
  • New Topic