There is a VERY similar question to mine but in my case I don\'t have any duplicate jars in my build path, so the solution does not work for me. I\'ve searched google for a
As for every "3rd-party" library in flavor of a JAR file which is to be used by the webapp, just copy/drop the physical JAR file in webapp's /WEB-INF/lib
. It will then be available in webapp's default classpath. Also, Eclipse is smart enough to notice that. No need to hassle with buildpath. However, make sure to remove all unnecessary references you added before, else it might collide.
An alternative is to install it in the server itself by dropping the physical JAR file in server's own /lib
folder. This is required when you're using server-provided JDBC connection pool data source which in turn needs the MySQL JDBC driver.
Many times I have been facing this problem, I have experienced ClassNotFoundException. if jar is not at physical location.
So make sure .jar file(mysql connector) in the physical location of WEB-INF lib folder. and make sure restarting Tomcat by using shutdown command in cmd. it should work.
Ok, after had the same issue and after reading some answers here and other places. it seems that putting external lib
into WEB-INF/lib
is not that good idea as it pollute webapp/JRE libs with server-specific libraries
- for more information check this answer"
Another solution that i do NOT recommend is: to copy it into tomcat/lib folder. although this may work, it will be hard to manage dependency for a shared(git for example) project.
Create vendor
folder. put there all your external lib. then, map this folder as dependency to your project. in eclipse you need to
build path
Project Properties
-> Java build path
Libraries
-> add external lib or any other solution to add your files/folderdeployment Assembly
(reference)
Project Properties
-> Deployment Assembly
Add
-> Java Build Path Entries
Use maven
(or any alternative) to manage project dependency
Place mysql-connector-java-5.1.6-bin.jar to the \Apache Tomcat 6.0.18\lib folder. Your problem will be solved.
Just follow these steps:
1) Install eclipse
2) Import Apache to eclipse
3) Install mysql
4) Download mysqlconnector/J
5) Unzip the zipped file navigate through it until you get the bin file in it. Then place all files that are present in the folder containing bin to C:\Program Files\mysql\mysql server5.1/
then give the same path as the address while defining the driver in eclipse.
That's all very easy guys.
My issue was a little different. Instead of jdbc:oracle:thin:@server:port/service
i had it as server:port/service
.
Missing was jdbc:oracle:thin:@
in url
attribute in GlobalNamingResources.Resource. But I overlooked tomcat exception's
java.sql.SQLException: Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL 'server:port/service'