06.29.07

java:comp exception in Tomcat 6

Posted in General at 8:58 am by Steven

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 »

  1. Chad said,

    August 24, 2010 at 9:54 am

    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.

  2. Catherine said,

    July 7, 2011 at 9:07 am

    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 Comment