Java.lang.ClassNotFoundException: Com.mysql.jdbc.Driver
I am getting java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
in my dynamic web application even though I have set build path correctly in Eclipse
for mysql connector
. I am pretty sure that I have set built path correctly. I doubled checked that.
I ran through so many same kind of questions in stackoverflow. All of them suggest to set build path in Eclipse
.
My question is, are there any other ways that can generate java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
error? If so , how to solve that?
Thank you!
Answer
Keep your mysql-connector-java.jar
file inside Web-INF
folder -> lib
and add it in classpath and then export your WAR and deploy.
This Documentation - http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
says
Therefore, from the perspective of a web application, class or resource loading looks in the following repositories, in this order:
- Bootstrap classes of your JVM
/WEB-INF/classes
of your web application/WEB-INF/lib/*.jar
of your web application<----------
- System class loader classes (described above)
- Common class loader classes (described above)
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM