logstash-plugins/logstash-input-jdbc

Java::oracle.jdbc.driver.OracleDriver not loaded in logstash-7.2.0

snazzypramod opened this issue · 3 comments

Hi,

I am using logstash-7.2.0. I want to export data from oracle to ES. I am having following configuration.

OS: window10 enterprise

file name: oracle.conf

input {
jdbc{
jdbc_driver_library => "C:/Pramod/rnd/ElasticSearch/logstash-7.2.0/ojdbc7.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
jdbc_connection_string => "jdbc:oracle:thin:@//myOracleConnectionString:1521/GSEM4GE"
jdbc_user => "APPS_GLOBAL"
jdbc_password => "mypassword"
statement => "SELECT * FROM all_tables"
}
}
output {
elasticsearch {
hosts => ["http://localhost:9200"]
index => "oracleindex"
}
stdout{
codec => rubydebug
}
}

when i am trying to execute this config file on command prompt it says "Java::oracle.jdbc.driver.OracleDriver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?".

Error: Java::oracle.jdbc.driver.OracleDriver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?
Exception: LogStash::ConfigurationError
Stack: C:/Pramod/rnd/ElasticSearch/logstash-7.2.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:/Pramod/rnd/ElasticSearch/logstash-7.2.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:221:in execute_statement'
C:/Pramod/rnd/ElasticSearch/logstash-7.2.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:277:in execute_query' C:/Pramod/rnd/ElasticSearch/logstash-7.2.0/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:263:in run'
C:/Pramod/rnd/ElasticSearch/logstash-7.2.0/logstash-core/lib/logstash/java_pipeline.rb:309:in inputworker' C:/Pramod/rnd/ElasticSearch/logstash-7.2.0/logstash-core/lib/logstash/java_pipeline.rb:302:in block in start_input'

Pls help.

The problem is that with JDK 11 the plugin stop loading the JDBC drivers due to the casting to URLClassLoader. Solved with PR #356. Probably you have to update the plugin or put the jar with JDBC driver into the classpath.

For me it worked to put an empty string into the jdbc_driver_library value and to put the ojdbc*jar file into the folder /logstash-core/lib/jars.

input { jdbc{ jdbc_driver_library => "" jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver" jdbc_connection_string => "jdbc:oracle:thin:@//myOracleConnectionString:1521/GSEM4GE" jdbc_user => "APPS_GLOBAL" jdbc_password => "mypassword" statement => "SELECT * FROM all_tables" } } output { elasticsearch { hosts => ["http://localhost:9200"] index => "oracleindex" } stdout{ codec => rubydebug } }

This conf works for me.

Jar file location:
logstash-core\lib\jars\ojdbc7.jar

kares commented

as suggested by @andsel LS 7.2 included the old plugin version which has issues with driver loading.
while the work-around is okay, for issues reported please try updating to latest plugin version first ...
please also make sure file permissions for the .jar esp. if running LS as a service (under logstash user)