Logstash JDBC Plugin Driver Not Loaded Error


(Jeromefroe) #1

Hello all, I have been trying to use the jdbc input plugin for logstash but keep getting a driver not loaded error. Specifically, I am using logstash-2.0.0 and the oracle jdbc jar (ojdbc6.jar). I have seen similar issues on Github (e.g. https://github.com/logstash-plugins/logstash-input-jdbc/issues/43) relating to specifying the name of the driver class correctly, but I am using the name explicitly specified in the documentation ( https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#plugins-inputs-jdbc-jdbc_driver_class). The exact error I'm getting is "Error: Java::oracle.jdbc.driver.OracleDriver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?". My config file (had to scrub some connection details) is:

input {
  jdbc {
    jdbc_driver_library => "/opt/logstash/lib/ojdbc6.jar"
    jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
    jdbc_connection_string => "jdbc:oracle:thin:@ldap://example.com:389/db01,dc=example,dc=com"
    jdbc_user => "user"
    jdbc_password => "password"
    parameters => { "Where_Clause" => "O%"}
    schedule => "* * * * *"
    statement => "SELECT * from MAIN"
  }
}
output {file{ path=> "/home/test.txt"}}

I was wondering if this might be a logstash-2.0.0 issue? Thanks!

EDIT: The issue was with the jdbc jar file, it had been corrupted. After re-downloading the jar everything is working fine!

.


(Anish) #2

Hi , I am getting exactly the same error
"
Error: java::oracle.jdbc.driver.OracleDriver not loaded. Are you sure you've inc
luded the correct jdbc driver in :jdbc_driver_library?
You may be interested in the '--configtest' flag which you can
use to validate logstash's configuration before you choose
to restart a running system.
"
but didn't worked after re-downloading the jar. I am using logstash-2.1.0. Configuration test is OK
Below is my config

input {
jdbc {
jdbc_driver_library => "E:/Lab/jdbc_driver/ojdbc6.jar"
jdbc_driver_class => "java::oracle.jdbc.driver.OracleDriver"
jdbc_connection_string => "jdbc:oracle:thin:@//192.168.1.2:1521/testdb"
jdbc_user => "usr"
jdbc_password => "password"
jdbc_validate_connection => true
parameters => { "person_id" => "10001" }
statement => "SELECT * FROM person where person_id = :person_id"
}
}
output {
elasticsearch {
index => "person_id"
document_type => "person"
document_id => "%{uid}"
hosts => "127.0.0.1:9200"
}


(Jeromefroe) #3

Hey Anish, could you try unzipping the JAR and and viewing the files inside? The problem I had was that when I downloaded the JAR file from the command line onto to my virtual machine, the JAR file was actually empty because Oracle requires a username and password (it was very confusing because the download appeared to go smoothly, but when I unzipped the JAR, after trying many other things, it was empty). I ended up downloading the JAR using my web browser on my local machine, unzipping the JAR to make sure it was not empty, and then copying the JAR onto my virtual machine. Since then everything has worked perfectly.


(Anish) #4

Thank you Jeromefroe.
I could see many class files when unpacking the jar, so I think jar is not corrupted.


(Jeromefroe) #5

Hey Anish, the only other suggestion I have is to try capitalizing the J in Java in the connection string. So "java::oracle.jdbc.driver.OracleDriver" becomes "Java::oracle.jdbc.driver.OracleDriver". Good Luck!


(Anish) #6

Thanks a lot Jeromefroe, it worked for me :slight_smile:


(Jeromefroe) #7

Awesome!


(system) #8