Spark2 Thrift Server

Limitation Overview

Spark2 Thrift Server requires JDK 1.8 (Java 8) and is not compatible with JDK 11 or higher versions.

Description

Apache Spark 2.x components, including the Spark2 Thrift Server, were designed and tested exclusively with JDK 1.8. These components will fail to start or exhibit undefined behavior when running on JDK 11 or newer Java versions.

In cluster environments where the default Java version is JDK 11+, Spark2 Thrift Server must be explicitly configured to use JDK 1.8 to function properly.

Error Traces:

Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.apache.spark.sql.hive.client.IsolatedClientLoader.createClient(IsolatedClientLoader.scala:273) ... 26 more Caused by: java.lang.NoClassDefFoundError: java/sql/SQLTransientException at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:413) at org.apache.hadoop.hive.ql.session.SessionState.<init>(SessionState.java:389) at org.apache.spark.sql.hive.client.HiveClientImpl.newState(HiveClientImpl.scala:193) at org.apache.spark.sql.hive.client.HiveClientImpl.<init>(HiveClientImpl.scala:131) ... 31 more

Workaround

Solution

Configure Spark2 to use JDK 1.8 while allowing the rest of the cluster to use JDK 11+.

Configuration Location: Ambari UI → Spark2 → Configs → Advanced spark2-env

Required Setting:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk

Action: Save the configuration and restart the Spark2 service.



  Last updated