Reputation: 863
I have included the mysql jdbc driver in my demo app.
/tmp/jettytmp$ find . -name "*.jar"
./jetty-0.0.0.0-8080-auth-0.1.war-_auth-any-7537667183570190622.dir/webapp/WEB-INF/lib/mysql-connector-java-5.1.38.jar
However, When I try to login my demo app, java.lang.ClassNotFoundException throws out:
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at org.eclipse.jetty.security.JDBCLoginService.connectDatabase(JDBCLoginService.java:197)
at org.eclipse.jetty.security.JDBCLoginService.loadUser(JDBCLoginService.java:238)
at org.eclipse.jetty.security.MappedLoginService.login(MappedLoginService.java:221)
at org.eclipse.jetty.security.JDBCLoginService.login(JDBCLoginService.java:222)
at org.eclipse.jetty.security.authentication.LoginAuthenticator.login(LoginAuthenticator.java:61)
at org.eclipse.jetty.security.authentication.FormAuthenticator.login(FormAuthenticator.java:194)
at org.eclipse.jetty.security.authentication.FormAuthenticator.validateRequest(FormAuthenticator.java:270)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:512)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
2016-03-12 15:41:32.894:WARN:oejs.JDBCLoginService:qtp1980086877-13: UserRealm Admin Login could not load user information from database
java.sql.SQLException: Can't connect to database
From the log, we can see the JDBCLoginService try to connect to the database, but the jdbc driver is not found. But the jdbc driver has already been included in the demo app? how to solve this issue, any comments are appreciated. My jetty verison is 9.2. And I using the following command to launch demo app: java -jar /*/jetty-distribution-9.2.15.v20160210/start.jar
Upvotes: 0
Views: 2009
Reputation: 9043
You are using an outdated/historic package name for the MySQL driver. You should update it to com.mysql.jdbc.Driver
in the configuration of your application, as documented here:
With MySQL Connector/J, the name of this class is com.mysql.jdbc.Driver.
Having done this, it will be found if mysql-connector-java-5.1.x.jar
is availble in the classpath at runtime.
Details for the configuration of the MySQL JDBC driver and it's usage can be found here at the official MySQL Connector/J (JDBC) Reference.
The latest MySQL JDBC connector is available for download here.
Upvotes: 3