java:comp exception in Tomcat 6

I don’t know if this will do anyone any good (please leave a comment if it helps you!), but I want to get myself into the habit of blogging these sort of things for the potential good of other web searchers out there.

We were having the following problem: when starting an web app in Tomcat 6 that uses JNDI to locate a database connection, we got the exception:
javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
Lots of people point out that this could be a problem with there being a JNDI implementation in the web app’s lib/, so that the app doesn’t get the global one defined by Tomcat, and they recommend removing all naming* JARs from lib/. But, in our case, it was catalina.jar that was causing the problem; it also includes a JNDI implementation.

2 Comments

  • Chad
    2010/08/24 - 09:54 | Permalink

    Even though this was an old post it saved me! Thanks a ton! We didn’t set the scope to “provided” while building in Maven.

  • Catherine
    2011/07/07 - 09:07 | Permalink

    Thanks a lot!!!!!!!!!!!!!!!!!!!

    I’ve been for over two weeks finding out what was wrong with my project and Tomcat 6.

    This post saved me. I tried removing catalina.jar, and this solution didn’t work for me. In my case I removed from WEB-INF/lib the libraries: naming-factory.jar, naming-factory-dbcp.jar, naming-resources.jar from my project.

    Once again, thanks a lot for the advice!!!!!

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.