6

I'm running into java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver

I can get around the error by putting jtds.jar file in the CATALINA_HOME/lib directory but this isn't an ideal solution as the application should be modular enough to be deployable on any server.

I have the jtds.jar file in [tomcat_dir]/webapps/myapp/WEB-INF/lib which is where I want it to be found from.

I know there are TONS of similar questions so I apologize if this is a duplicate but I've yet to be able to find a post that helps.

Why can't my app find the correct jtds.jar file which I've included in the app package? What do I need to do in order to get the app to recognize that jar file?

2
  • 1
    You don't have duplicates of the jar from other dependencies right? That has bitten my in the ass many many times. Commented Nov 28, 2012 at 18:27
  • I agree with @thatidiotguy. I strongly suspect your Tomcat also has that jar somewhere in classpath. Commented Nov 28, 2012 at 18:29

1 Answer 1

8

Tomcat 6 and higher demands that JDBC driver JARs appear in the server /lib, especially if you have JNDI data sources.

It might not be ideal, but you'll have to get over it. How often will you be changing app servers?

Sign up to request clarification or add additional context in comments.

3 Comments

I'm running Tomcat6. Would you know if Tomcat v6 has the same requirements? I don't change app servers very often. Just seemed like a better idea to avoid putting the jar file in the tomcat lib directory if I could
I don't see why you're so adverse to putting a JAR in the server /lib, especially since it's likely to be a shared resource. If every app on the Tomcat instance deals with MySQL, isn't it a good idea to make sure that the app server has the same JDBC driver for all apps?
Tomcat 6 appears to require it as well: see service provider mechanism for an explanation. tomcat.apache.org/tomcat-6.0-doc/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.