This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Spark in Action and have Jean-Georges Perrin on-line!
See this thread for details.
Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to JNDI-Cannot create resource instance

Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using Tomcat 5.5. I am trying to access the environmental entries that i have specified in web.xml through JNDI.

I have followed the same steps given in documentation of Tomcat but i am getting javax.naming.NamingException: Cannot create resource instance

In my web.xml i have made the entry as
Object factory for MyBean instances

Also in server.xml, i have specified

<Resource name="bean/MyBeanFactory" auth="Container"

Then I am trying to do the lookup

Context initCtx;
MyBean bean = new MyBean();
try {
initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
bean = (MyBean) envCtx.lookup("bean/MyBeanFactory");
} catch (NamingException e) {

This is when i get the exception.

Could any one help me out?

[ September 29, 2008: Message edited by: Krishan Chauhan ]
Krishan Chauhan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone help me out ?
Posts: 3281
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

Just rushing past this topic so quick note:

Does Tomcat allow you to look at the JNDI tree? IIRC Tomcat ships with a JndiServlet that can be used to list the content of a local JNDI tree. It is found in the "examples" Webapp. Run that and see if your bean is actually in the JNDI tree where you think it is...

Hope the helps?
Paper beats rock. Scissors beats tiny ad.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic