Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Classpath and DataSource within Tomcat

843838Sep 13 2005 — edited Nov 12 2005
Used software:
- Tomcat 5.5.11
- JDK 5.0
- Windows XP SP2

Problem statement:

I have a webapplication, called monitorclient, which uses a connection
to a database using a JNDI bound DataSource object through my context.xml file.
To connect to the database (SQL Server), I need several JAR files. Whenever I
place these JAR files inside the ${CATALINA_HOME}/common/lib directory,
everything seems to work fine.

However, I would like to place these JARs into my webapp's lib directory, which is:
${CATALINA_HOME}/webapps/monitorclient/WEB-INF/lib/
Whenever I do this, the driver class ...
com.microsoft.jdbc.sqlserver.SQLServerDriver
... seems to fail to be found.

The generated exception is:
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: 
  "org.apache.tomcat.dbcp.dbcp.SQLNestedException: 
    Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'".
I've read the Tomcat documentation about classloading, and I can't seem to find
any errors from my part. I queried the forums and google about this matter but
I don't seem to get any results.

Directory structure:
${CATALINA_HOME}
  /webapps/
    /monitorclient/
       /META-INF/
          context.xml -> has the DataSource
       /WEB-INF
          /classes/
            /com/.../[some java code]
          /lib/
            msbase.jar       --> when I place these jars here instead of in
            mssqlserver.jar      ${CATALINA_HOME}/commons/lib, classloading 
            msutil.jar           seems to fail.
     index.jsp
     blah.jsp
     [...].jsp
Any help, pointers or the like are greatly appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 10 2005
Added on Sep 13 2005
5 comments
382 views