theangryangel / logstash-output-jdbc

JDBC output for Logstash
MIT License
256 stars 101 forks source link

Not able to connect to oracle datasource while running logstash jdbc output plugin as docker image #116

Closed singlahitesh closed 6 years ago

singlahitesh commented 6 years ago

{:exception=>java.lang.RuntimeException: Failed to load driver class Java::oracle.jdbc.driver.OracleDriver in either of HikariConfig class loader or Thread context classloader, :backtrace=>["com.zaxxer.hikari.HikariConfig.setDriverClassName(com/zaxxer/hikari/HikariConfig.java:340)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)", "RUBY.setup_and_test_pool!(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-jdbc-5.3.0-java/lib/logstash/outputs/jdbc.rb:149)", "RUBY.register(/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-jdbc-5.3.0-java/lib/logstash/outputs/jdbc.rb:127)", "RUBY.register(/usr/share/logstash/logstash-core/lib/logstash/output_delegator_strategies/shared.rb:9)", "RUBY.register(/usr/share/logstash/logstash-core/lib/logstash/output_delegator.rb:43)", "RUBY.register_plugin(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:290)", "RUBY.register_plugins(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:301)", "org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613)", "RUBY.register_plugins(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:301)", "RUBY.start_workers(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:310)", "RUBY.run(/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:235)", "RUBY.start_pipeline(/usr/share/logstash/logstash-core/lib/logstash/agent.rb:408)", "java.lang.Thread.run(java/lang/Thread.java:748)"]}

theangryangel commented 6 years ago

Failed to load driver class Java::oracle.jdbc.driver.OracleDriver.

Either you've given it the wrong path to the jar, or the wrong jar.

singlahitesh commented 6 years ago

No, same config is working when running logstash extracted from jar

singlahitesh commented 6 years ago

My config : output { jdbc { driver_jar_path => "/usr/share/logstash/ojdbc6.jar" driver_class => "Java::oracle.jdbc.driver.OracleDriver" connection_string => "" statement =>[ "some query"] } }

Docker image contents :

RUN mkdir /usr/share/logstash/log \ && /usr/share/logstash/bin/logstash-plugin install logstash-output-jdbc \ && /usr/share/logstash/bin/logstash-plugin update logstash-output-jdbc

theangryangel commented 6 years ago

Try removing the Java:: from your driver_class. That shouldn't be necessary.

singlahitesh commented 6 years ago

Removing Java:: from driver class is working for jdbc output plugin. Surprisingly jdbc input plugin mentions to add Java:: in driver class for correct working of input plugin with ojdbc6.jar