• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading environment entry from a custom tag ..  RSS feed

 
Ant Swa
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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..
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • 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
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!