| Author |
Exception: Name [jdbc:/comp/env] is not bound in this Context
|
chaitanya karthikk
Ranch Hand
Joined: Sep 15, 2009
Posts: 779
|
|
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 http://www.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.
|
Love all, trust a few, do wrong to none.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14561
|
|
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
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
chaitanya karthikk
Ranch Hand
Joined: Sep 15, 2009
Posts: 779
|
|
|
Thanks a lot Mr. Tim.
|
 |
 |
|
|
subject: Exception: Name [jdbc:/comp/env] is not bound in this Context
|
|
|