Unable to connect to database. Tried 1 times {:error_message=>"Java::JavaLang::NoClassDefFoundError: javax/xml/bind/DatatypeConverter"

I am trying to move a table form SQL Server to ElasticSearch with Logstash
I have installed elasticsearch and logstash 7.3.1 with docker-compose.

pipeline/logstash has the following configuration:

input {
tcp {
port => 5000
input {
jdbc {
jdbc_validate_connection => false
jdbc_driver_library => ""
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://server:1433;databaseName=databasename;integratedSecurity=false;"
jdbc_user => "xx"
jdbc_password => "xxxx"
statement => "SELECT * FROM dbo.Table"
#Add your filters / logstash plugins configuration here
output {
elasticsearch {
hosts => "elasticsearch:9200"
user => "elastic"
password => "changeme"

According to a recommended workaround in this page I have copied directly sqljdbc42.jar in /usr/share/logstash/logstash-core/lib/jars

Being the Dockerfile of logstash:


FROM docker.elastic.co/logstash/logstash:${ELK_VERSION}

RUN logstash-plugin install logstash-filter-jdbc_streaming
RUN logstash-plugin install logstash-filter-aggregate
RUN logstash-plugin install logstash-input-jdbc
RUN logstash-plugin install logstash-filter-translate

COPY ./jars /usr/share/logstash/logstash-core/lib/jars
COPY ./jars /usr/share/logstash/jars
COPY ./config /usr/share/logstash/config
COPY ./pipeline /usr/share/logstash/pipeline

#Add your logstash plugins setup here
#Example: RUN logstash-plugin install logstash-filter-json

It is not working, the docker logs of logstash is :

[2019-09-24T15:14:52,339][ERROR][logstash.inputs.jdbc ] Unable to connect to database. Tried 1 times {:error_message=>"Java::JavaLang::NoClassDefFoundError: javax/xml/bind/DatatypeConverter"}
[2019-09-24T15:14:52,341][ERROR][logstash.javapipeline ] A plugin had an unrecoverable error. Will restart this plugin.
Error: Java::JavaLang::NoClassDefFoundError: javax/xml/bind/DatatypeConverter
Exception: Sequel::DatabaseConnectionError
Stack: com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(com/microsoft/sqlserver/jdbc/SQLServerConnection.java:4098)

Currently I am block, please, could anybody help me?

I'm having the same issue (after using that workaround). Did you get past this?

i was able to solve this issue by removing the installed java version, reinstall java 8 openjdk and setting the JAVA_HOME path

I don't know if it's required but I also added java_home/bin to the path variable

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