This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Exception: Name [jdbc:/comp/env] is not bound in this Context

 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I am using tomcat 7.x and trying to do JNDI lookup and get DataSource instance. When i try to use Context's lookup(String name) method it is not working. I am gettingWhen I try to do the same with @Resource(name = "jdbc/mytest") I am able to get the DataSource instance and my application is working fine. Why is this problem occurring?

I declared the resource in server.xml file asand a resource-ref in my web.xml like thisBefore using @Resource I tried putting the Resource in context.xml file under META-INF folder also. But everything failed. I read here https://coderanch.com/t/496324/Tomcat/jdbc-JNDI-name-causes-Tomcat that we have to check "Publish module contexts to separate xml files". I did this, even it dint work. Then after using @Resource I unchecked this and it worked.

Why am I not able to use Context's lookup(String name) method?

Thank you all in advance. Good day.
 
Saloon Keeper
Posts: 24331
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a basic problem in the JNDI lookup name. It's not "jdbc:/comp/env", it's "java:comp/env". Or, more fully:

java:comp/env/jdbc/mytest
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Mr. Tim.
 
I once met a man from Nantucket. He had a tiny ad
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic