Ubuntu Tomcat7 java.lang.ClassNotFoundException:org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory [英] Ubuntu Tomcat7 java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory

查看:542
本文介绍了Ubuntu Tomcat7 java.lang.ClassNotFoundException:org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Ubuntu 12.X下的Tomcat 7中设置JDBC数据源,因此我将以下内容添加到context.xml文件中:

I'm trying to set up a JDBC DataSource in Tomcat 7 under Ubuntu 12.X, so I added the following to the context.xml file:

<Resource name="jdbc/myDS" auth="Container" type="javax.sql.DataSource"
    maxActive="5" maxIdle="2" maxWait="5000"
    driverClassName="org.postgresql.Driver" username="usr" password="***" url="jdbc:postgresql://localhost:5432/db" />

显然,使用正确的和经过测试的数据库用户ID和密码.重新启动Tomcat时,出现以下错误:

Obviously, using the right and tested database user id and password. When I restart Tomcat, I get the this error:

Feb 05, 2013 1:10:01 PM org.apache.catalina.core.NamingContextListener addResource
WARNING: Failed to register in JMX: javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory]

我用Google搜索,发现必须将JDBC驱动程序复制到$ CATALINA_HOME/lib文件夹,因此我将postgresql-9.2-1000.jdbc4.jar复制到/usr/share/tomcat7/lib,但是没有帮不上忙.我尝试将文件复制到其他位置,但结果相同.

I googled, and found out the JDBC driver has to be copied to the $CATALINA_HOME/lib folder, so I copied the postgresql-9.2-1000.jdbc4.jar to /usr/share/tomcat7/lib, but it didn't help. I tried copying the file to other locations, with the same results.

另一种尝试是将/usr/share/tomcat7/lib中的tomcat-dbcp.jar符号链接从../../java/tomcat-dbcp-7.0.30.jar更改为../../java /tomcat-dbcp.jar.唯一的变化是我只得到一个警告,而不是四个警告,但是数据源也不起作用.

Another attempt was to change the tomcat-dbcp.jar symlink in /usr/share/tomcat7/lib from ../../java/tomcat-dbcp-7.0.30.jar to ../../java/tomcat-dbcp.jar. The only change was I got only one warning instead of four, but the datasource doesn't work either.

Java版本:

jdoe@sever:~$ java -version
java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.4) (7u9-2.3.4-0ubuntu1.12.10.1)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

任何提示,非常欢迎.

干杯.

推荐答案

存储库中的库tomcat-dbcp-7.0.30.jar已损坏.

替换为:

sudo wget -O /usr/share/java/tomcat-dbcp-7.0.30.jar http://search.maven.org/remotecontent?filepath=org/apache/tomcat/tomcat-dbcp/7.0.30/tomcat-dbcp-7.0.30.jar

这篇关于Ubuntu Tomcat7 java.lang.ClassNotFoundException:org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆