tags:

views:

1115

answers:

3

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

+2  A: 

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.

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

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

skaffman
I never remember the driver class names. These times I wish JDBC had automatic driver discovery.
kd304
skaffman,I specified driver class in context.xml as following:driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
kilonet
please post the relevent part of your context.xml file.
skaffman
<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" />
kilonet
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
laz
A: 

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

kilonet