You are right ... it shouldn't be put there.  One thing you didn't seem
to mention is how you are using your mysql driver.   Are you trying to
use the built-in database pooling?  If that's the case, the mysql driver
should be in tomcat's lib directory because tomcat's internals need
access to it as well.  Also can you offer some detail about your use of
hibernate?  If it's in your webapp, it should easily see the driver jar
file.  If it's in another webapp, it won't.

--David

Bob Marcum wrote:
> I have been experiencing "java.lang.ClassNotFoundException:
> com.mysql.jdbc.Driver" when attempting to run my webapp under tomcat
> 6.0.18.  I have run my application successfully before under prior
> versions of Tomcat. I have found and implemented a solution that
> works, but I believe it is a "wrong" solution and I want to provoke
> some discussion about a "right" solution.  Let me explain:
>
> My environment:
>     Tomcat 6.0.18
>     jse 1.6.0_05
>     using hibernate 3.0
>     using mySQL standard-4.1.14
> My development environment is driven by Ant 1.6.5
> and ... irrelevant to the issue but ... my front end code is Google
> Web Toolkit (GWT) based.
>
> Now ...
> I kept getting mysql driver class not found at runtime.  I have the
> driver mysql-connector-java-3.1.10-bin.jar file in myapp/WEB-INF/lib. 
> I would have thought that would have solved the problem in a nice,
> tidy fashion, but it did not.  After further investigation of the
> Tomcat 6 class loading mechanism I found this bit of information:
> "...plus classes and resources in JAR files under the /WEB-INF/lib
> directory of your web application archive, are made visible to the
> containing web application, but to no others."  I believe I am being
> caught on that "but to no others" phrase.  That would mean code
> directly in my app could see all the jar files in WEB-INF/lib but
> hibernate code, for instance, could not ?? !! even though conceptually
> the hibernate code is configured to be an integral part of my app ??
>
> A solution I found to work is to copy the
> mysql-connector-java-3.1.10-bin.jar file into my jseHOME/jre/lib/ext
> directory.  Now my app can see the driver at runtime just fine.  But
> ... that seems a "wrong" solution to me.  A "right" solution would
> bundle access to that jar file into the  configuration of my webapp,
> which is what I expect and get when I put library jar files in
> WEB-INF/lib.
>
> Is there a "more right" solution that allows me to keep the library
> jar files for the mysql driver more closely bundled with my app,
> rather than force it to be seen be all users of java se 1.6.0_05?? ...
> and still meet the requirements of Tomcat's class loading mechanisms?
>
> Thanks.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to