Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

known incompatibility with oracle + sybase driver on class-path #99

Open
kares opened this issue Dec 16, 2021 · 3 comments
Open

known incompatibility with oracle + sybase driver on class-path #99

kares opened this issue Dec 16, 2021 · 3 comments
Labels
known issue wontfix This will not be worked on

Comments

@kares
Copy link
Contributor

kares commented Dec 16, 2021

When both jconn4.jar (Sybase JDBC driver) and ojdbc11.jar (Oracle JDBC driver) are on Logstash's class-path, driver auto-loading (with DriverManager) occasionally leads to issues.

Confirmed versions that exhibit the behavior:

  • jConnect for JDBC(TM)/7.07 SP100
    (Build 26 846)/P/EBF20990/JDK 1.6.0/jdbcmain/OPT/Wed Apr 24 11:30:54 PDT 2013
  • Oracle JDBC 21.1.0.0.0

Failures usually looks like if the Sybase driver did not load (Java::com.sybase.jdbc4.jdbc.SybDriver not loaded):

Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc ... jdbc_driver_class=>"Java::com.sybase.jdbc4.jdbc.SybDriver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_077dffc1-173c-44ce-98a0-a0141e2c6d82", 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, plugin_timezone=>"utc", clean_run=>false, record_last_run=>true, lowercase_column_names=>true>
Error: Java::com.sybase.jdbc4.jdbc.SybDriver not loaded. :jdbc_driver_library is not set, are you sure you included the proper driver client libraries in your classpath? ["/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sequel-5.50.0/lib/sequel/adapters/jdbc.rb:68:in `load_driver'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.1.8/lib/logstash/plugin_mixins/jdbc/common.rb:33:in `load_driver'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-integration-jdbc-5.1.8/lib/logstash/inputs/jdbc.rb:294:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:405:in `inputworker'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:396:in `block in start_input'"]
Exception: LogStash::PluginLoadingError

but might also surface as Java::oracle.jdbc.driver.OracleDriver not loaded and depend on execution order with multiple inputs.

sample native traces when running with plugin >= 5.1.10 :

java.lang.NoClassDefFoundError: Could not initialize class oracle.jdbc.driver.OracleDriver
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(java/lang/Class.java:398)
	at org.jruby.javasupport.JavaSupportImpl.loadJavaClass(org/jruby/javasupport/JavaSupportImpl.java:157)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(jdk/internal/reflect/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(jdk/internal/reflect/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:566)
	at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:456)
	at org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:317)
	at home.kares.workspace.work.elastic.plugins.logstash_minus_integration_minus_jdbc.lib.logstash.plugin_mixins.jdbc.common.load_jdbc_driver_class(/home/kares/workspace/work/elastic/plugins/logstash-integration-jdbc/lib/logstash/plugin_mixins/jdbc/common.rb:81)
	at RUBY.load_driver(/home/kares/workspace/work/elastic/plugins/logstash-integration-jdbc/lib/logstash/plugin_mixins/jdbc/common.rb:35)
	at RUBY.run(/home/kares/workspace/work/elastic/plugins/logstash-integration-jdbc/lib/logstash/inputs/jdbc.rb:294)
	at RUBY.inputworker(/home/kares/workspace/work/elastic/sdh/823/logstash/logstash-core/lib/logstash/java_pipeline.rb:405)
	at RUBY.start_input(/home/kares/workspace/work/elastic/sdh/823/logstash/logstash-core/lib/logstash/java_pipeline.rb:396)
	at org.jruby.RubyProc.call(org/jruby/RubyProc.java:318)
	at java.lang.Thread.run(java/lang/Thread.java:829)
java.lang.NoClassDefFoundError: Could not initialize class com.sybase.jdbc4.jdbc.SybDriver
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(java/lang/Class.java:398)
	at org.jruby.javasupport.JavaSupportImpl.loadJavaClass(org/jruby/javasupport/JavaSupportImpl.java:157)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(jdk/internal/reflect/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(jdk/internal/reflect/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:566)
	at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:456)
	at org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:317)
	at home.kares.workspace.work.elastic.plugins.logstash_minus_integration_minus_jdbc.lib.logstash.plugin_mixins.jdbc.common.load_jdbc_driver_class(/home/kares/workspace/work/elastic/plugins/logstash-integration-jdbc/lib/logstash/plugin_mixins/jdbc/common.rb:81)
	at home.kares.workspace.work.elastic.plugins.logstash_minus_integration_minus_jdbc.lib.logstash.plugin_mixins.jdbc.common.RUBY$method$load_jdbc_driver_class$0$__VARARGS__(home/kares/workspace/work/elastic/plugins/logstash_minus_integration_minus_jdbc/lib/logstash/plugin_mixins/jdbc//home/kares/workspace/work/elastic/plugins/logstash-integration-jdbc/lib/logstash/plugin_mixins/jdbc/common.rb)
	at home.kares.workspace.work.elastic.plugins.logstash_minus_integration_minus_jdbc.lib.logstash.plugin_mixins.jdbc.common.load_driver(/home/kares/workspace/work/elastic/plugins/logstash-integration-jdbc/lib/logstash/plugin_mixins/jdbc/common.rb:35)
	at RUBY.run(/home/kares/workspace/work/elastic/plugins/logstash-integration-jdbc/lib/logstash/inputs/jdbc.rb:294)
	at RUBY.inputworker(/home/kares/workspace/work/elastic/sdh/823/logstash/logstash-core/lib/logstash/java_pipeline.rb:405)
	at RUBY.start_input(/home/kares/workspace/work/elastic/sdh/823/logstash/logstash-core/lib/logstash/java_pipeline.rb:396)
	at org.jruby.RubyProc.call(org/jruby/RubyProc.java:318)
	at java.lang.Thread.run(java/lang/Thread.java:829)

https://stackoverflow.com/questions/54960627/getting-java-lang-noclassdeffounderror-could-not-initialize-class-oracle-jdbc-o

a potential work-around is to not put these drivers on the class-path at the same time (under $LS_HOME/logstash-core/lib/jars) and instead use the jdbc_driver_library => configuration option. also worth checking latest versions of the drivers whether they still exhibit the behavior.


p.s. might be a good candidate for #93

@kares kares added known issue wontfix This will not be worked on labels Dec 16, 2021
@kares
Copy link
Contributor Author

kares commented Dec 16, 2021

this is a known issue with SAP (implementation vendor of the Sybase driver).

@kares
Copy link
Contributor Author

kares commented Dec 27, 2021

potential alternative might be to switch to the jTDS driver (using jdbc:jtds:sybase:// uri format), the driver is unmaintained for years (so is jConnect Sybase driver) but should be working for the simple requirements the JDBC input has on a JDBC driver.

@Praveen-Natarajan
Copy link

Any work around found for this issue ? I am facing this exact issue in my application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
known issue wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants