1

When I ran my web application under Eclipse IDE everything worked fine. But when I exported my project into war-file and deployed in tomcat I've got following message:

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc

I've tried putting sqljdbc4.jar everywhere:

  • catalina-home\lib dir
  • WEB-INF\lib dir
  • both of them

What I'am missing? Environment: tomcat 6.0.20, sql server 2005

3 Answers 3

4

The driver class is "com.microsoft.sqlserver.jdbc.SQLServerDriver". You've just missed the class name off the end.

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

5 Comments

I never remember the driver class names. These times I wish JDBC had automatic driver discovery.
skaffman, I specified driver class in context.xml as following: driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
please post the relevent part of your context.xml file.
<Resource name="jdbc/db_name" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" url="jdbc:sqlserver://localhost;databaseName=db_name" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" username="sa" password="sa" />
For that configuration to work in the deployed version of your web application the JAR containing com.microsoft.sqlserver.jdbc.SQLServerDriver has to be in $CATALINA_HOME/lib
3

Your driver class name is wrong. The exception text points to a package, not an actual driver class. And don't forget to restart Tomcat after changing the contents of various lib directories.

Edit: Your IDE might use different configuration than your deployed war. Or fail with the same exception silently but the driver itself was already loaded by other means - then the actual connection just works.

4 Comments

thnks for feedback What you mean by saying "Your driver class is wrong" - that driver works fine under IDE
Regardless of what your IDE is doing, "com.microsoft.sqlserver.jdbc" is not a driver class, it's a package.
I feel silly, but what conclusions I should draw from >>>"com.microsoft.sqlserver.jdbc" is not a driver class, it's a package
In general, if you see these kind of error messages, check your configuration for mistypes.
0

blah... After reinstalling tomcat it worked just fine. As kd304 said - maybe it was configuration issue Thanks for your help

Comments

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.