Unable to find driver class via URLClassLoader in given driver jars: com.mysql.jdbc.Driver and com.mysql.jdbc.Driver
配置详情
input{
stdin{
}
jdbc{
jdbc_driver_library => "mysql-connector-java-5.1.48-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/rulian"
jdbc_user => "root"
jdbc_password => "root"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
codec => plain { charset => "UTF-8"}
statement => "SELECT id,code,create_time,eff_start_time,eff_stop_time,ip,mark,remark,update_time FROM base_ip where update_time > :sql_last_value"
clean_run => false
use_column_value => false
schedule => "* * * * *"
type => "jdbc"
}
}
output{
stdout{
codec => json_lines
}
elasticsearch{
hosts => ["http://localhost:9200"]
index => "base_ip"
document_id => "%{id}"
}
}
问题描述
{ 2016 rufus-scheduler intercepted an error:
2016 job:
2016 Rufus::Scheduler::CronJob “* * * * *” {}
2016 error:
2016 2016
2016 LogStash::PluginLoadingError
2016 Unable to find driver class via URLClassLoader in given driver jars: com.mysql.jdbc.Driver and com.mysql.jdbc.Driver
2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.16/lib/logstash/plugin_mixins/jdbc/jdbc.rb:181:in open_jdbc_connection' 2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.16/lib/logstash/plugin_mixins/jdbc/jdbc.rb:253:in
execute_statement’
2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.16/lib/logstash/inputs/jdbc.rb:309:in execute_query' 2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.16/lib/logstash/inputs/jdbc.rb:276:in
block in run’
2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:234:in do_call' 2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:258:in
do_trigger’
2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:300:in block in start_work_thread' 2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:299:in
block in start_work_thread’
2016 org/jruby/RubyKernel.java:1425:in loop' 2016 C:/Users/dxm/Documents/software/elk/logstash-7.4.2/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:289:in
block in start_work_thread’
2016 tz:
2016 ENV[‘TZ’]:
2016 Time.now: 2019-11-06 12:10:27 +0800
2016 scheduler:
2016 object_id: 2012
2016 opts:
2016 {:max_work_threads=>1}
2016 frequency: 0.3
2016 scheduler_lock: #Rufus::Scheduler::NullLock:0x3547c804
2016 trigger_lock: #Rufus::Scheduler::NullLock:0x513c9604
2016 uptime: 136.492 (2m16s492)
2016 down?: false
2016 threads: 2
2016 thread: #Thread:0x2e6582f4
2016 thread_key: rufus_scheduler_2012
2016 work_threads: 1
2016 active: 1
2016 vacant: 0
2016 max_work_threads: 1
2016 mutexes: {}
2016 jobs: 1
2016 at_jobs: 0
2016 in_jobs: 0
2016 every_jobs: 0
2016 interval_jobs: 0
2016 cron_jobs: 1
2016 running_jobs: 1
2016 work_queue: 0
尝试的方法
尝试过很多办法,比如:换驱动器版本号、换JDK版本等措施,折腾了1.5天,结果是都不行。
最终解决方法
将驱动器即mysql-connector-java-5.1.48-bin.jar拷贝到 logstash目录\logstash-core\lib\jars 下,上述问题就可解决。