Apache James gives: ClassNotFoundException: com.mysql.jdbc.Driver

可紊 提交于 2019-12-12 04:13:56

问题


I've configured Apache James as per the wiki:

thufir@dur:~/apache-james-3.0-beta4$ 
thufir@dur:~/apache-james-3.0-beta4$ tail bin/setenv.sh 
# limitations under the License.
# ----------------------------------------------------------------------------
#
# Add every needed extra jar to this
CLASSPATH_PREFIX=../conf/lib/*
export CLASSPATH_PREFIX



CLASSPATH_PREFIX=../conf/lib/mysql-connector-java-5.1.21-bin.jar
thufir@dur:~/apache-james-3.0-beta4$ 
thufir@dur:~/apache-james-3.0-beta4$ ll conf/lib/
total 824
drwxr-xr-x 2 thufir thufir   4096 Aug 16 19:40 ./
drwxr-xr-x 4 thufir thufir   4096 Aug 16 18:56 ../
-rw-r--r-- 1 thufir thufir 827942 Jun 21 06:41 mysql-connector-java-5.1.21-bin.jar
-rw------- 1 thufir thufir     66 Mar 21 03:33 README.txt
thufir@dur:~/apache-james-3.0-beta4$ 
thufir@dur:~/apache-james-3.0-beta4$ cat conf/james-database.properties 
# MySQL JDBC database properties
database.driverClassName=com.mysql.jdbc.Driver
database.url=jdbc:mysql://localhost/james
database.username=james
database.password=password
vendorAdapter.database=MYSQL
openjpa.streaming=false

thufir@dur:~/apache-james-3.0-beta4$ 

But I'm getting:

jvm 1    |  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
jvm 1    |  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
jvm 1    |  at java.lang.reflect.Method.invoke(Method.java:616)
jvm 1    |  at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
jvm 1    |  at java.lang.Thread.run(Thread.java:679)
jvm 1    | Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
jvm 1    |  at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1429)
jvm 1    |  at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
jvm 1    |  at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
jvm 1    |  at org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:137)
jvm 1    |  at org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:112)
jvm 1    |  at org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(DataSourceFactory.java:239)
jvm 1    |  ... 98 more
jvm 1    | Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
jvm 1    |  at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
jvm 1    |  at java.security.AccessController.doPrivileged(Native Method)
jvm 1    |  at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
jvm 1    |  at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
jvm 1    |  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
jvm 1    |  at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
jvm 1    |  at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1420)
jvm 1    |  ... 103 more
jvm 1    | 
jvm 1    |  at org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(ConfigurationImpl.java:309)
jvm 1    |  at org.apache.openjpa.conf.OpenJPAConfigurationImpl.instantiateAll(OpenJPAConfigurationImpl.java:1652)
jvm 1    |  at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:645)
jvm 1    |  at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:204)
jvm 1    |  ... 80 more
wrapper  | <-- Wrapper Stopped
thufir@dur:~/apache-james-3.0-beta4$ 
thufir@dur:~/apache-james-3.0-beta4$ 
thufir@dur:~/apache-james-3.0-beta4$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu2)
OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)
thufir@dur:~/apache-james-3.0-beta4$ 

The full console output was too large to paste here.

What am I doing wrong? The JDBC JAR is there, it's in the script, and MySql is configured.

Oh, I'm using OpenJDK 6 because there's a problem with JDK 7 and James, although I expect that only applies if you're using the JDK and not just the JRE as I am.

I can see that this isn't the first time around on this question, perhaps.


回答1:


Courtesy of Eric Charles:

From: Eric Charles <eric <at> apache.org>
Subject: Re: mysql driver
Newsgroups: gmane.comp.jakarta.james.user
Date: 2012-08-17 10:48:28 GMT (13 minutes ago)

The conf/lib/*.jar loading in beta4 is buggy.

Can you edit the conf/wrapper.conf and change 
'wrapper.java.classpath...=../conf/lib' to 
'wrapper.java.classpath...=../conf/lib/*' (add a /* after lib).

Thx, Eric

although I need to test it out a bit.




回答2:


I solved this problem by adding line "wrapper.java.classpath.133=%REPO_DIR%/mysql-connector-java-5.1.36.jar" to wrapper.conf



来源:https://stackoverflow.com/questions/11999233/apache-james-gives-classnotfoundexception-com-mysql-jdbc-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!