javamysqljdbcbenchmarkingycsb

YCSB JDBS driver: java.lang.ClassNotFoundException


While trying to load data to MySQL I am getting following error:

    ~/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

I have set my db.properties (in ~/YCSB folder) as follows:

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=

and I already created lib folder in "~/YCSB/jdbc" and put the "mysql-connector-java-5.1.46-bin.jar" there.


Solution

  • What you think is a comment, isn't. In a properties file, the # only denotes a comment if it is the first non-whitespace character on a line.

    From Properties.load(Reader):

    A comment line has an ASCII '#' or '!' as its first non-white space character;

    This is demonstrated by the fact the error message contains that comment:

    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver # The JDBC driver class to use.

    In other words, change

    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=
    

    to

    # 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=
    

    Or remove the comments entirely