无法加载JDBC驱动程序类' org.neo4j.jdbc.Driver'

时间:2017-01-08 21:51:12

标签: tomcat jdbc neo4j

我有jsp webapp在我的本地主机上运行Tomcat 8.5时工作正常但是当我把它放在服务器上时,我得到无法加载驱动程序异常。

(如果它应该有所不同,服务器是在Amazon EC2上运行的Ubuntu 16)

我已经检查过jar是在home / lib文件夹中。 运行tomcat的用户拥有权限(我的jstl jar工作)。 我试图重新加载deamon并重新启动服务。

我一直在寻找关于这个主题的过多线索,但找不到正确的答案(尽管我确信它已经存在)。

这是我的(相关)背景:

  <Resource name="jdbc/MyDB"
        auth="Container"
        type="javax.sql.DataSource"
        username="myname"
        password="mypass"
        driverClassName="org.neo4j.jdbc.Driver"
        url="jdbc:neo4j:bolt://localhost"
        maxActive="8"
        maxIdle="4"/>

(名称和密码显然不是真正的名称)

这是暴露错误的类中的代码:

        Context initContext = new InitialContext();
        Context webContext = (Context)initContext.lookup("java:/comp/env");
        DataSource ds = (DataSource) webContext.lookup("jdbc/MyDB");
        con = ds.getConnection();

这是我的堆栈跟踪:

Unfortunately something went wrong. This to be specific:
java.sql.SQLException: Cannot load JDBC driver class 'org.neo4j.jdbc.Driver'
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2145)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2037)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1543)
at myapp.model.neo4j.LoginHandler.login(LoginHandler.java:24)
at myapp.control.LoginServlet.doPost(LoginServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.neo4j.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2136)
... 28 more

1 个答案:

答案 0 :(得分:0)

确保使用正确的neo4j-jdbc-driver-3.0.1.jar。

(不是像neo4j-jdbc-3.0.1.jar这样名称相似的其他文件)