Logstash com.mysql.jdbc.Driver error

Hi. I have logstash 7.4.2 , mysql 5.7 , This is my config:

filter {
  jdbc_static {
    loaders => [ 
      {
        id => "products-table"
        query => "select id,name from products;"
        local_table => "products"
       }
    ]
    local_db_objects => [
      {
        name => "products"
        index_columns => ["id"]
        columns => [
          ["id", "int(11)"],
          ["name", "varchar(100)"]
        ]
      }
    ]
    local_lookups => [ 
      {
        id => "get-product-name"
        query => "SELECT name FROM products WHERE id = :pid"
        parameters => { pid => "[product]" }
        target => "product_name"
      }
    ]
    jdbc_driver_library => "mysql-connector-java-5.1.48-bin.jar"
    loader_schedule => "* */1 * * *"
    jdbc_user => "user"
    jdbc_password => "pass"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://IP:3306/dbname"
  }
}

The jar file is in the directory and I've installed plugin with logstash-plugin install logstash-input-jdbc.
I get this error:

 [2020-08-17T19:20:04,679][ERROR][logstash.javapipeline    ][main] Pipeline aborted due to error {:pipeline_id=>"main", :exception=>#<TypeError: failed to coerce jdk.internal.loader.ClassLoaders$AppClassLoader to java.net.URLClassLoader>, :backtrace=>["org/jruby/java/addons/KernelJavaAddons.java:29:in `to_java'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-jdbc_static-1.0.6/lib/logstash/filters/jdbc/basic_database.rb:88:in `verify_connection'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-jdbc_static-1.0.6/lib/logstash/filters/jdbc/read_only_database.rb:48:in `post_create'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-jdbc_static-1.0.6/lib/logstash/filters/jdbc/basic_database.rb:33:in `create'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-jdbc_static-1.0.6/lib/logstash/filters/jdbc/loader.rb:18:in `build_remote_db'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-jdbc_static-1.0.6/lib/logstash/filters/jdbc_static.rb:178:in `block in prepare_runner'", "org/jruby/RubyArray.java:2584:in `map'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-jdbc_static-1.0.6/lib/logstash/filters/jdbc_static.rb:175:in `prepare_runner'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-jdbc_static-1.0.6/lib/logstash/filters/jdbc_static.rb:146:in `register'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:56:in `register'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:195:in `block in register_plugins'", "org/jruby/RubyArray.java:1800:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:194:in `register_plugins'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:468:in `maybe_setup_out_plugins'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:207:in `start_workers'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:149:in `run'",
"/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:108:in `block in start'"], :thread=>"#<Thread:0x61c745f5 run>"}
[2020-08-17T19:20:04,701][ERROR][logstash.agent           ] Failed to execute action {:id=>:main, :action_type=>LogStash::ConvergeResult::FailedAction, :message=>"Could not execute action: PipelineAction::Create<main>, action_result: false", :backtrace=>nil}

What should I do ? Thanx

Try to use the full absolute path to the .jar file for jdbc_driver_library.

You might want to read through some of the issues that link to this and this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.