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?