Summary
Client applications running Arrow Flight SQL JDBC driver 16.1.0+ with Java 8 fail to return query results and report the error:
java.lang.NoSuchMethodError: java.nio.ByteBuffer.rewind()Ljava/nio/ByteBuffer
Reported Issue
When querying Dremio with a client application that uses the the Arrow Flight SQL JDBC driver, results are not returned and the following error stack (or a very similar one) is be reported:
Exception in thread "main" java.lang.NoSuchMethodError: java.nio.ByteBuffer.rewind()Ljava/nio/ByteBuffer;
at org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.vector.ipc.message.MessageSerializer.readMessage(MessageSerializer.java:704)
at org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.vector.ipc.message.MessageSerializer.deserializeSchema(MessageSerializer.java:213)
at org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.sql.FlightSqlClient$PreparedStatement.deserializeSchema(FlightSqlClient.java:1034)
at org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.sql.FlightSqlClient$PreparedStatement.getResultSetSchema(FlightSqlClient.java:998)
at org.apache.arrow.driver.jdbc.client.ArrowFlightSqlClientHandler$1.getDataSetSchema(ArrowFlightSqlClientHandler.java:278)
at org.apache.arrow.driver.jdbc.ArrowFlightMetaImpl.prepareForHandle(ArrowFlightMetaImpl.java:166)
at org.apache.arrow.driver.jdbc.ArrowFlightMetaImpl.prepareAndExecute(ArrowFlightMetaImpl.java:196)
at org.apache.arrow.driver.jdbc.shaded.org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:677)
at org.apache.arrow.driver.jdbc.shaded.org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:157)
at org.apache.arrow.driver.jdbc.shaded.org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:228)
...
Note that, prior to this error, the client has successfully connected to Dremio and has submitted a job. In the Dremio jobs listing you can even observe the "[Prepare Statement Arrow Flight]" job that proceeds the actual execution. The exception occurs in the client app just prior to the query execution.
Relevant Versions
Arrow Flight JDBC driver 16.1.0+ connecting to Dremio versions that support Arrow Flight SQL (all currently supported Dremio versions).
Troubleshooting Steps
Ensure that your client application will catch and print the exception produced by the Arrow Flight SQL JDBC driver. This may require you to enable debug logging.
Check which version of Java is running the client application java code.
Check which version of the Arrow Flight SQL JDBC driver you are using. This should be indicated in the name of the driver JAR file. Versions 16.1.0+ show this problem.
Cause
As the error suggests, the Java 8 standard library class java.nio.ByteBuffer lacks a method required by the 16.1.0+ driver.
Steps to Resolve
The best solution is to change the Java runtime for the client application to Java 11+
Another possible workaround is to downgrade the driver to 16.0.0 or lower.