logstash-plugins/logstash-input-jdbc

“Unable to find driver class” when use jdbc_driver_library => “/home/ubuntu/ojdbc6.jar” after upgrade to Logstash 6.8.4

Closed this issue · 5 comments

The latest release of Logstash 6.8.4 with jdbc-input-plugin 4.3.16 give us following error in syslog

Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172   job:
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172     Rufus::Scheduler::CronJob "*/1 * * * *" {}
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172   error:
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172     2172
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172     LogStash::PluginLoadingError
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172     Unable to find driver class via URLClassLoader in given driver jars: Java::oracle.jdbc.driver.OracleDriver and Java::oracle.jdbc.driver.OracleDriver
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/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'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.16/lib/logstash/plugin_mixins/jdbc/jdbc.rb:253:in `execute_statement'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.16/lib/logstash/inputs/jdbc.rb:309:in `execute_query'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.16/lib/logstash/inputs/jdbc.rb:276:in `block in run'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:234:in `do_call'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:258:in `do_trigger'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:300:in `block in start_work_thread'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:299:in `block in start_work_thread'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       org/jruby/RubyKernel.java:1425:in `loop'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172       /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:289:in `block in start_work_thread'
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172   tz:
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172     ENV['TZ']:
Oct 24 21:02:00 ip-10-40-0-99 logstash[15520]:   2172     Time.now: 2019-10-24 21:02:00 +0900

our pipeline config looks like

        jdbc_driver_library => "/home/ubuntu/ojdbc6.jar"
        jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"

OS Info

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.5 LTS
Release:	16.04
Codename:	xenial

JDK info

$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

It was fine when running Logstash 6.8.2 and 6.8.3 with jdbc-input-plugin 4.3.13.
So I guess something wrong with the Driver loading modification for jdbc-input-plugin 4.3.14. and 4.3.15 release

A workaround for us is to not using jdbc_driver_library but place the ojdbc6.jar in logstash-core lib path

install -C -m 644 -o logstash -g logstash /home/ubuntu/ojdbc6.jar /usr/share/logstash/logstash-core/lib/jars

Hi @JerseyGood loading of drivers has changed recently, please could you try with 4.3.18 version and report here if the problem persists?

@andsel Thanks for the reply, will give it a try with 4.3.18 of jdbc-input-plugin and share the result.

But we are installing Logstash through apt and the latest stable version logstash is 1:6.8.4-1 which I believe by default uses jdbc-input-plugin 4.3.16

https://www.elastic.co/guide/en/logstash/6.8/logstash-6-8-4.html

Do you know when will logstash bump up the version to use jdbc-input-plugin 4.3.18

I've run into a very similar-looking problem with Logstash 7.4, installed on Ubuntu 18.0.4 with the "apt-get" instructions listed here: https://www.elastic.co/guide/en/logstash/current/installing-logstash.html

$ echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
$ sudo apt-get update && sudo apt-get install logstash
$ /usr/share/logstash/bin/logstash --version
logstash 7.4.2

Trying to connect to a MySQL database with the JDBC connector mysql-connector-java-8.0.18.jar, Logstash just kept failing with plugin loading errors. But this error went away when I updated the logstash-input-jdbc plugin:

$ sudo /usr/share/logstash/bin/logstash-plugin update logstash-input-jdbc
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.headius.backport9.modules.Modules to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of com.headius.backport9.modules.Modules
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Updating logstash-input-jdbc
Updated logstash-input-jdbc 4.3.16 to 4.3.18

This is a very tricky problem to diagnose! 4.3.18 should be made the default plugin version ASAP, to avoid this bug, AFAICS.

I can confirm this is fixed with logstash 6.8.5

This was fixed by #355 and is fixed by the latest release of the jdbc input.

Running bin/logstash-plugin update logstash-input-jdbc should get you to 4.3.19 (this fix landed in 4.3.18):

/tmp/logstash-7.5.0
❯ bin/logstash-plugin update logstash-input-jdbc
Updating logstash-input-jdbc
Updated logstash-input-jdbc 4.3.16 to 4.3.19

Version >=4.3.19 will be shipped in 7.5.1