YCSB JDBS驱动程序:java.lang.ClassNotFoundException

时间:2018-03-24 01:09:42

标签: java mysql jdbc benchmarking ycsb

在尝试将数据加载到MySQL时,我遇到以下错误:

    ~/YCSB$ bin/ycsb load jdbc -P workloads/workloada -P db.properties
[WARN] Running against a source checkout. In order to get our runtime dependencies we'll have to invoke Maven. Depending on the state of your system, this may take ~30-45 seconds
[DEBUG] Running 'mvn -pl com.yahoo.ycsb:jdbc-binding -am package -DskipTests dependency:build-classpath -DincludeScope=compile -Dmdep.outputFilterFile=true'
/usr/lib/jvm/java-8-oracle/bin/java -cp /home/zakaria/YCSB/jdbc/conf:/home/zakaria/YCSB/jdbc/target/jdbc-binding-0.14.0-SNAPSHOT.jar:/home/zakaria/.m2/repository/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1.jar:/home/zakaria/.m2/repository/org/apache/htrace/htrace-core4/4.1.0-incubating/htrace-core4-4.1.0-incubating.jar:/home/zakaria/.m2/repository/net/sourceforge/serp/serp/1.13.1/serp-1.13.1.jar:/home/zakaria/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.4/HdrHistogram-2.1.4.jar:/home/zakaria/.m2/repository/org/apache/openjpa/openjpa-jdbc/2.1.1/openjpa-jdbc-2.1.1.jar:/home/zakaria/.m2/repository/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar:/home/zakaria/.m2/repository/org/apache/openjpa/openjpa-kernel/2.1.1/openjpa-kernel-2.1.1.jar:/home/zakaria/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.4/jackson-core-asl-1.9.4.jar:/home/zakaria/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/zakaria/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar:/home/zakaria/YCSB/core/target/core-0.14.0-SNAPSHOT.jar:/home/zakaria/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.9.4/jackson-mapper-asl-1.9.4.jar:/home/zakaria/.m2/repository/org/apache/openjpa/openjpa-lib/2.1.1/openjpa-lib-2.1.1.jar:/home/zakaria/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar com.yahoo.ycsb.Client -db com.yahoo.ycsb.db.JdbcDBClient -P workloads/workloada -P db.properties -load
Command line: -db com.yahoo.ycsb.db.JdbcDBClient -P workloads/workloada -P db.properties -loadYCSB Client 0.14.0-SNAPSHOT

Loading workload...
Starting test.
Error in initializing the JDBS driver: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver  # The JDBC driver class to use.
com.yahoo.ycsb.DBException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver # The JDBC driver class to use.
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:220)
at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:86)
at com.yahoo.ycsb.ClientThread.run(Client.java:423)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver  # The JDBC driver class to use.
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:194)
... 3 more
com.yahoo.ycsb.DBException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver # The JDBC driver class to use.
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:220)
at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:86)
at com.yahoo.ycsb.ClientThread.run(Client.java:423)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver  # The JDBC driver class to use.
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.yahoo.ycsb.db.JdbcDBClient.init(JdbcDBClient.java:194)
... 3 more
[OVERALL], RunTime(ms), 5
[OVERALL], Throughput(ops/sec), 0.0
[TOTAL_GCS_PS_Scavenge], Count, 0
[TOTAL_GC_TIME_PS_Scavenge], Time(ms), 0
[TOTAL_GC_TIME_%PS_Scavenge], Time(%), 0.0
[TOTAL_GCS_PS_MarkSweep], Count, 0
[TOTAL_GC_TIME_PS_MarkSweep], Time(ms), 0
[TOTAL_GC_TIME%PS_MarkSweep], Time(%), 0.0
[TOTAL_GCs], Count, 0
[TOTAL_GC_TIME], Time(ms), 0
[TOTAL_GC_TIME%], Time(%), 0.0

我已经设置了我的db.properties(在〜/ YCSB文件夹中),如下所示:

db.driver=com.mysql.jdbc.Driver # The JDBC driver class to use.
db.url=jdbc:mysql://master:3306/ycsb # The Database connection URL.
db.user=root # User name for the connection.
db.passwd=

我已经在“〜/ YCSB / jdbc”中创建了lib文件夹,并将“mysql-connector-java-5.1.46-bin.jar”放在那里。

2 个答案:

答案 0 :(得分:1)

您认为评论是什么,不是。在属性文件中,#仅表示注释,如果它是一行中的第一个非空白字符。

来自Properties.load(Reader)

  

注释行的ASCII '#''!'为第一个非空格字符;

错误消息包含该注释的事实证明了这一点:

  

java.lang.ClassNotFoundException:com.mysql.jdbc.Driver #要使用的JDBC驱动程序类。

换句话说,改变

db.driver=com.mysql.jdbc.Driver # The JDBC driver class to use.
db.url=jdbc:mysql://master:3306/ycsb # The Database connection URL.
db.user=root # User name for the connection.
db.passwd=

# The JDBC driver class to use.
db.driver=com.mysql.jdbc.Driver 
# The Database connection URL.
db.url=jdbc:mysql://master:3306/ycsb 
# User name for the connection.
db.user=root 
db.passwd=

或完全删除评论

答案 1 :(得分:1)

我通过删除注释并在pom.xml中添加以下依赖项(在/ PATH / YCSB / jdbc路径中)解决了这个问题:

<dependency>
      <groupId>com.mysql.driver</groupId>
      <artifactId>mysqldriver</artifactId>
      <version>5.1.46</version>
      <scope>system</scope>
      <systemPath>/PATH/YCSB/jdbc/lib/mysql-connector-java-5.1.46-bin.jar</systemPath>
</dependency>