How to fix 'java.lang.NoClassDefFoundError: io/fabric8/kubernetes/api/model/apps/Deployment'

10/29/2019

I have been trying to integrate spark interpreter on zeppelin (v0.7.3) on a Kubernetes cluster. However, as a complication of having k8s version 1.13.10 on the servers https://issues.apache.org/jira/browse/SPARK-28921

I needed to upgrade my spark k8s-client to v4.6.1 as indicated here https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/issues/591#issuecomment-526376703

But when I try executing a spark command sc.version on zeppelin-ui, I get:

ERROR [2019-10-25 03:45:35,430] ({pool-2-thread-4} Job.java[run]:181) - Job failed
java.lang.NullPointerException
 at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:38)
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:33)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkContext_2(SparkInterpreter.java:398)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkContext(SparkInterpreter.java:387)
    at org.apache.zeppelin.spark.SparkInterpreter.getSparkContext(SparkInterpreter.java:146)
    at org.apache.zeppelin.spark.SparkInterpreter.open(SparkInterpreter.java:843)
    at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:70)

Here are the spark-submit configurations I have, but I don't think the error was from these (since I've run these before and they worked fine)

spark.kubernetes.driver.docker.image=x
spark.kubernetes.executor.docker.image=x
spark.local.dir=/tmp/spark-local
spark.executor.instances=5 
spark.dynamicAllocation.enabled=true
spark.shuffle.service.enabled=true
spark.kubernetes.shuffle.labels="x"
spark.dynamicAllocation.maxExecutors=5
spark.dynamicAllocation.minExecutors=1 
spark.kubernetes.docker.image.pullPolicy=IfNotPresent
spark.kubernetes.resourceStagingServer.uri="http://xxx:xx"

I have tried downgrading the spark-k8s client to 3.x.x until 4.0.x but I get the HTTP error. Thus, I've decided to stick to v4.6.1 . Opening the zeppelin-interpreter logs, I find the following stack-trace:

ERROR [2019-10-25 03:45:35,428] ({pool-2-thread-4} Utils.java[invokeMethod]:40) -
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:38)
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:33)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkSession(SparkInterpreter.java:378)
    at org.apache.zeppelin.spark.SparkInterpreter.getSparkSession(SparkInterpreter.java:233)
    at org.apache.zeppelin.spark.SparkInterpreter.open(SparkInterpreter.java:841)
    at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:70)
    at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:491)
    at org.apache.zeppelin.scheduler.Job.run(Job.java:175)
    at org.apache.zeppelin.scheduler.FIFOScheduler$1.run(FIFOScheduler.java:139)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: io/fabric8/kubernetes/api/model/apps/Deployment
    at io.fabric8.kubernetes.client.internal.readiness.Readiness.isReady(Readiness.java:62)
    at org.apache.spark.scheduler.cluster.k8s.KubernetesExternalShuffleManagerImpl$anonfun$start$1.apply(KubernetesExternalShuffleManager.scala:82)
    at org.apache.spark.scheduler.cluster.k8s.KubernetesExternalShuffleManagerImpl$anonfun$start$1.apply(KubernetesExternalShuffleManager.scala:81)
    at scala.collection.Iterator$class.foreach(Iterator.scala:893)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at org.apache.spark.scheduler.cluster.k8s.KubernetesExternalShuffleManagerImpl.start(KubernetesExternalShuffleManager.scala:80)
    at org.apache.spark.scheduler.cluster.k8s.KubernetesClusterSchedulerBackend$anonfun$start$1.apply(KubernetesClusterSchedulerBackend.scala:212)
    at org.apache.spark.scheduler.cluster.k8s.KubernetesClusterSchedulerBackend$anonfun$start$1.apply(KubernetesClusterSchedulerBackend.scala:212)
    at scala.Option.foreach(Option.scala:257)
    at org.apache.spark.scheduler.cluster.k8s.KubernetesClusterSchedulerBackend.start(KubernetesClusterSchedulerBackend.scala:212)
    at org.apache.spark.scheduler.TaskSchedulerImpl.start(TaskSchedulerImpl.scala:173)
    at org.apache.spark.SparkContext.<init>(SparkContext.scala:509)
    at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2509)
    at org.apache.spark.sql.SparkSession$Builder$anonfun$6.apply(SparkSession.scala:909)
    at org.apache.spark.sql.SparkSession$Builder$anonfun$6.apply(SparkSession.scala:901)
    at scala.Option.getOrElse(Option.scala:121)
    at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:901)
    ... 20 more
 INFO [2019-10-25 03:45:35,430] ({pool-2-thread-4} SparkInterpreter.java[createSparkSession]:379) - Created Spark session
ERROR [2019-10-25 03:45:35,430] ({pool-2-thread-4} Job.java[run]:181) - Job failed
java.lang.NullPointerException
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:38)
    at org.apache.zeppelin.spark.Utils.invokeMethod(Utils.java:33)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkContext_2(SparkInterpreter.java:398)
    at org.apache.zeppelin.spark.SparkInterpreter.createSparkContext(SparkInterpreter.java:387)
    at org.apache.zeppelin.spark.SparkInterpreter.getSparkContext(SparkInterpreter.java:146)
    at org.apache.zeppelin.spark.SparkInterpreter.open(SparkInterpreter.java:843)
    at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:70)
    at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:491)
    at org.apache.zeppelin.scheduler.Job.run(Job.java:175)
    at org.apache.zeppelin.scheduler.FIFOScheduler$1.run(FIFOScheduler.java:139)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
 INFO [2019-10-25 03:45:35,431] ({pool-2-thread-4} SchedulerFactory.java[jobFinished]:137) - Job remoteInterpretJob_1571975134433 finished by scheduler org.apache.zeppelin.spark.SparkInterpreter819422312

I expect to run this command:

%spark
%sc.version 

P.S. This is my first post here, so if I did not follow certain rules, kindly correct me. Thanks!

-- Joshua Villanueva
apache-spark
apache-zeppelin
kubernetes

1 Answer

11/5/2019

After some rigorous research and help from my colleagues, I was able to verify that io/fabric8/kubernetes/api/model/apps/Deployment didn't exist at Kubernetes-model-v2.0.0. Upgrading the jar to v3.0.0 fixed the issue.

-- Joshua Villanueva
Source: StackOverflow