Closed Lumos-Nox closed 6 years ago
Such problems will mostly not caused by the applications and its libraries. In most cases it is a problem at the setup. So please double and tripple check your setup. Maybe you can provide more details.
@klaushauschild1984 Thanks for your comment. Let me make it clearer....
The setup of the project needs the following JAR files:
If I put all JAR files mentioned above in /Library/Java/Extensions, then compile and
build the project, and restart tomcat and run the web application, everything works
fine.
If I keep mysql-connector-java-5.1.23-bin.jar in /Library/Java/Extensions, but other
JAR files are moved to $CATALINA_HOME/lib, and repeat the above steps in the first
case, everything works fine again!
If I do the same thing in the second case except that the
mysql-connector-java-5.1.23-bin.jar is moved to $CATALINA_HOME/lib, an error
(500 - Internal Server Error) happens. [Root Cause is: java.sql.SQLException:
No suitable driver].
I have developed a web application using servlet but import java.sql.* rather than
org.sql2o.*, also mysql-connector-java-5.1.23-bin.jar is moved to $CATALINA_HOME/lib,
but this time the web application works correctly as it should do.
I have explained the setup thoroughly, now it is your turn. :-) Thanks again. dofadore
@Lumos-Nox I do understand that you have an issue, but it has to do with Tomcat and how third-party libraries are added to it. Please consult the Tomcat Classloading guide at https://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html Having said that, adding libraries to the system Java runtime is generally considered to be a bad idea as it makes your application less portable. Usually, database drivers are provided by the application server (i.e Tomcat) or bundled with your application (for instance in the WEB-INF/lib folder of a WAR file). Closing this issue now
Hi, I'm using tomcat and sql2o to develop web application, but sql2o could not load mysql-connector-java-5.1.23-bin.jar in $CATALINA_HOME/lib, only when this jar file was placed in /Library/Java/Extensions/ directory did it work. Besides, using java native library to require a data source also works. Thanks in advance.