Error: org.postgresql.Driver not loaded


(easy) #1

I have problem with jdbc_driver_library.

ELK_VERSION = 6.4.2

And I use Docker for elk.

when i run:

/opt/logstash# bin/logstash --path.data=/opt/logstash/ -f /etc/logstash/conf.d/simple.conf

Get Error:
Error: org.postgresql.Driver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?

Exception: LogStash::ConfigurationError
Stack: /opt/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:163:in open_jdbc_connection' /opt/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:221:inexecute_statement'
/opt/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:277:in execute_query' /opt/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/inputs/jdbc.rb:263:inrun'
/opt/logstash/logstash-core/lib/logstash/pipeline.rb:409:in inputworker' /opt/logstash/logstash-core/lib/logstash/pipeline.rb:403:inblock in start_input'
^C[2018-11-08T08:07:23,329][WARN ][logstash.runner ] SIGINT received. Shutting down.
[2018-11-08T08:07:24,688][INFO ][logstash.pipeline ] Pipeline has terminated {:pipeline_id=>"main", :thread=>"#<Thread:0x40ce6e2c run>"}
^C[2018-11-08T08:07:26,309][FATAL][logstash.runner ] SIGINT received. Terminating immediately..
[2018-11-08T08:07:26,531][ERROR][org.logstash.Logstash ] org.jruby.exceptions.ThreadKill

simple.conf :

input {
jdbc {
type => "test"
jdbc_driver_library => "/etc/logstash/org.postgresql.jdbc4-8.3-603.jar"
jdbc_driver_class => "org.postgresql.Driver"
jdbc_connection_string => "jdbc:postgresql://xxxx:8080/dbname"
jdbc_user => "xxxxx"
jdbc_password => "xxxx"
jdbc_page_size => "50000"
record_last_run => true
#schedule => "*/5 * * * *"
###example statement
statement => "SELECT jj.id as id,
jjp.title as job,
FROM jobs AS jj
INNER JOIN jobs_job AS jjp ON jj.id=jjp.job_id
WHERE jj.active = true"

}
}

path to jdbc_driver_library:

root@xxxxxxx:/etc/logstash# ls
conf.d mysql-connector-java-8.0.12.jar org.postgresql.jdbc4-8.3-603.jar
root@xxxxxxxxxx:/etc/logstash#

I do not understand why, because sometimes it works and sometimes does not work?


(easy) #3

I solved the problem:

First check your java version:

root@xxxxxx:/# java -version
openjdk version "1.8.0_181"

If you are using 1.8 then you should use the JDBC42 version.
If you are using 1.7 then you should use the JDBC41 version.
If you are using 1.6 then you should use the JDBC43 version.

postgres setup:

postgresql-9.4-1203.jdbc42.jar

jdbc_driver_library => '/path_to_jar/postgresql-9.4-1203.jdbc42.jar'
jdbc_driver_class => 'org.postgresql.Driver'


(system) #4

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