5

The Problem

I'm trying to connect to a Apache Ignite server with Apache Ignite built-in tool, SQLLine. I get the error: java.lang.NoClassDefFoundError: Could not initialize class org.apache.ignite.IgniteJdbcThinDriver

Background

I have Apache Ignite running in a container and CentOS7 running in another container. Both containers running in the same network (pinging works both ways). The tried connection is happening from CentOS7 to Apache Ignite.

Apache Ignite seems to be running fine with just the default configuration. In the CentOS7 container, I have installed Oracle JDK 12.0.1 and I have Apache Ignite 2.7.0 binary files in a folder. I have also set the IGNITE_HOME environmental variable.

Here, (https://apacheignite-sql.readme.io/docs/sqlline), it says I can connect to my cluster with just: ./sqlline.sh --verbose=true -u jdbc:ignite:thin://127.0.0.1/. However, this throws the previously mentioned error.

SQLLine should come with Ignite JDBC drivers. I have tried downloading them manually (https://apacheignite-sql.readme.io/docs/jdbc-driver#section-multiple-endpoints). When I downloaded the driver, which is said to be the ignite-core-{version}.jar, I put it in the same folder as sqlline.jar files.

Output

[root@bc72c4fbf47e bin]# ./sqlline.sh
sqlline version 1.3.0
sqlline> !connect jdbc:ignite:thin://172.19.0.2/
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.ignite.internal.util.GridUnsafe$2 (file:/var/tmp/apache-ignite/libs/ignite-core-2.7.0.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of org.apache.ignite.internal.util.GridUnsafe$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
java.lang.NoClassDefFoundError: Could not initialize class org.apache.ignite.IgniteJdbcThinDriver
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:415)
    at java.sql/java.sql.DriverManager.isDriverAllowed(DriverManager.java:555)
    at java.sql/java.sql.DriverManager.isDriverAllowed(DriverManager.java:547)
    at java.sql/java.sql.DriverManager.getDrivers(DriverManager.java:449)
    at java.sql/java.sql.DriverManager.getDrivers(DriverManager.java:426)
    at sqlline.SqlLine.findRegisteredDriver(SqlLine.java:1568)
    at sqlline.SqlLine.scanForDriver(SqlLine.java:1542)
    at sqlline.Commands.connect(Commands.java:1074)
    at sqlline.Commands.connect(Commands.java:1001)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
    at sqlline.SqlLine.dispatch(SqlLine.java:791)
    at sqlline.SqlLine.begin(SqlLine.java:668)
    at sqlline.SqlLine.start(SqlLine.java:373)
    at sqlline.SqlLine.main(SqlLine.java:265)

Conclusion

I should be able to connect to my Ignite server with !connect jdbc:ignite:thin://172.19.0.2/ command in sqlline. This does not work, and throws Could not initialize class org.apache.ignite.IgniteJdbcThinDriver IgniteJDBCThinDriver is installed/available.

MoffeeCug
  • 63
  • 1
  • 5

4 Answers4

6

Adding JVM argument

--add-opens java.base/java.nio=ALL-UNNAMED

solved the problem for me.

Nolequen
  • 3,032
  • 6
  • 36
  • 55
4

It is recommended to Java 8, as Apache Ignite 2.7.0 does not have full Java 12 support. Otherwise you can try tinkering with JVM options.

alamar
  • 18,729
  • 4
  • 64
  • 97
1

Thank you @alamar, that worked!

I uninstalled JDK12 that i had installed with RPM. Check the package name: rpm -qa | grep jdk. Delete the package: rpm -e jdk-12.0.1-12.0.1-ga.x86_64.

I'm working on a isolated system, so I downloaded and transferred JDK8.rpm from another machine. Install JDK8: rpm -ihv jdk-8u211-linux-x64.rpm.

Now when I run: ./sqlline.sh --verbose=true -u jdbc:ignite:thin://172.19.0.2, I get: issuing: !connect jdbc:ignite:thin://172.19.0.2/ '' '' org.apache.ignite.IgniteJdbcTh Connecting to jdbc:ignite:thin://172.19.0.2/ Connected to: Apache Ignite (version 2.7.0#20181130-sha1:256ae401) Driver: Apache Ignite Thin JDBC Driver (version 2.7.0#20181130-sha1:256ae401) Autocommit status: true Transaction isolation: TRANSACTION_REPEATABLE_READ sqlline version 1.3.0.

I can now query my database.

MoffeeCug
  • 63
  • 1
  • 5
0

I got this error in the following very strange situation:

A dependency of my maven java project had Apache-Ignite as a dependency. The moment I opened a connection to a SQLite database at an invalid path (e.g. ./result/r.sqlite where the folder ./result does not exist) this error occurred (using th driver org.xerial.sqlite-jdbc:v3.30.1.)So this call

Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:result.sqlite")

would result in this stacktrace:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.apache.ignite.IgniteJdbcThinDriver
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at java.sql/java.sql.DriverManager.isDriverAllowed(DriverManager.java:555)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:674)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)
    at MyClass.myMethod(MyClass.java:154)

So the solution would obviously be to make sure the folder exsits where the sqlite database should be created in.