Error: com.mysql.jdbc.Driver not loaded

(prabhat kumar rana) #1

i am getting this error

[2019-05-17T12:49:58,687][ERROR][logstash.inputs.jdbc ] Failed to load C:\Users\shiwani\Downloads\ELK\mysql-connector-java-5.1.47\mysql-connector-java-5.1.47-bin.jar {:exception=>#<TypeError: failed to coerce jdk.internal.loader.ClassLoaders$AppClassLoader to java.net.URLClassLoader>}
[2019-05-17T12:49:58,696][ERROR][logstash.javapipeline ] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"root", jdbc_password=>, statement=>"SELECT * FROM users", jdbc_driver_library=>"C:\Users\shiwani\Downloads\ELK\mysql-connector-java-5.1.47\mysql-connector-java-5.1.47-bin.jar", jdbc_connection_string=>"jdbc:mysql://localhost:3306/ration", id=>"51233e2f5943938b45ba6f8237494163b8ca46d61d8ae71dbe8ee64a1148c15b", jdbc_driver_class=>"com.mysql.jdbc.Driver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_7d85ef90-cac3-4eec-9c56-500018ee32dc", enable_metric=>true, charset=>"UTF-8">, jdbc_paging_enabled=>false, jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", connection_retry_attempts=>1, connection_retry_attempts_wait_time=>0.5, parameters=>{"sql_last_value"=>1970-01-01 00:00:00 UTC}, last_run_metadata_path=>"C:\Users\shiwani/.logstash_jdbc_last_run", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true>
Error: com.mysql.jdbc.Driver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?
Exception: LogStash::ConfigurationError
Stack: C:/Users/shiwani/Downloads/ELK/logstash-7.0.0/logstash-7.0.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:163:in open_jdbc_connection' C:/Users/shiwani/Downloads/ELK/logstash-7.0.0/logstash-7.0.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:221:inexecute_statement'
C:/Users/shiwani/Downloads/ELK/logstash-7.0.0/logstash-7.0.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:277:in execute_query' C:/Users/shiwani/Downloads/ELK/logstash-7.0.0/logstash-7.0.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:263:inrun'
C:/Users/shiwani/Downloads/ELK/logstash-7.0.0/logstash-7.0.0/logstash-core/lib/logstash/java_pipeline.rb:297:in inputworker' C:/Users/shiwani/Downloads/ELK/logstash-7.0.0/logstash-7.0.0/logstash-core/lib/logstash/java_pipeline.rb:290:inblock in start_input'
[2019-05-17T12:49:59,701][ERROR][logstash.inputs.jdbc ] Failed to load C:\Users\shiwani\Downloads\ELK\mysql-connector-java-5.1.47\mysql-connector-java-5.1.47-bin.jar {:exception=>#<TypeError: failed to coerce jdk.internal.loader.ClassLoaders$AppClassLoader to java.net.URLClassLoader>}
[2019-05-17T12:49:59,709][ERROR][logstash.javapipeline ] A plugin had an unrecoverable error. Will restart this plugin.

logstash.conf

input {
jdbc {
jdbc_connection_string => "jdbc:mysql://localhost:3306/ration"
# The user we wish to execute our statement as
jdbc_user => "root"
jdbc_password => ""
# The path to our downloaded jdbc driver
jdbc_driver_library =>"C:\Users\shiwani\Downloads\ELK\mysql-connector-java-8.0.16\mysql-connector-java-8.0.16\mysql-connector-java-8.0.16.jar"
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
# our query
statement => "SELECT * FROM users"
}
}
output {
stdout { codec => json_lines }
elasticsearch {
hosts => "localhost:9200"
index => "users"
document_type => "user"
document_id => "%{id}"
}
}

#2

Which version of Java are you using? If you are using anything newer than Java 8 can you install Java 8 and see if that works?

(prabhat kumar rana) #3

I am using java 12 on windows and for mysql i have insatlled xampp