JDBC领域身份验证 - ClassNotFoundException:com.mysql.jdbc.Driver

时间:2018-04-13 19:46:19

标签: java jdbc classnotfoundexception mysql-connector tomee

我知道这是一个重复的问题,但其他15个帖子的答案都没有帮助,或者我错过了什么。

我正在尝试在我的JAX-WS java web应用程序中使用JDBC Realm实现身份验证,我甚至无法连接到db。

这是我试过的:

环境变量:

使用:

  • Apache的tomee加1.7.4

  • jre1.8.0_161

  • jdk1.8.0_144

实际追踪:

Apr 13, 2018 9:07:49 PM org.apache.catalina.realm.JDBCRealm getPassword
SEVERE: Exception performing authentication
java.sql.SQLException: com.mysql.jdbc.Driver
    at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:692)
    at org.apache.catalina.realm.JDBCRealm.getPassword(JDBCRealm.java:544)
    at org.apache.catalina.realm.RealmBase.getDigest(RealmBase.java:1266)
    at org.apache.catalina.realm.RealmBase.authenticate(RealmBase.java:420)
    at org.apache.catalina.realm.CombinedRealm.authenticate(CombinedRealm.java:111)
    at org.apache.tomee.catalina.TomEERealm.authenticate(TomEERealm.java:55)
    at org.apache.catalina.authenticator.DigestAuthenticator$DigestInfo.authenticate(DigestAuthenticator.java:708)
    at org.apache.catalina.authenticator.DigestAuthenticator.authenticate(DigestAuthenticator.java:275)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:577)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:688)
    ... 20 more

1 个答案:

答案 0 :(得分:1)

像我一样惭愧,我不得不承认我在电脑上使用了错误的tomEE版本,甚至没有连接到eclipse,但我确信它是正确的,直到我检查了eclipse的实际路径。

无论如何,正如JDBC Realm所做的那样,和其他许多线程一样。建议的答案是,DBMS连接器.jar需要位于服务器的lib目录下($ CATALINA-HOME / lib)。