ajay.prajakta_128320 avatar image
ajay.prajakta_128320 asked Erick Ramirez answered

Getting "ClassNotFoundException: com.twitter.jsr166e.LongAdder" with Spark connector v1.2

Hi Team,

In our one of the old deployment we are using Datastax spark cassandra connector version 1.2.

Following are the versions of our components

  1. Cassandra - 2.0.4
  2. Spark - 1.2
  3. Spark Cassandra connector - 1.2

During our write from spark to cassandra we are getting java.lang.ClassNotFoundException: com.twitter.jsr166e.LongAdder exception. When we checked the Connector jar we could see the JSR166e is available. This jar is coming with connector pom. But in run time it is not able to find out the jar.

Code Snippet :

  .writerBuilder(keyspace COLUMN_FAMILY, CassandraJavaUtil.mapToRow(Class, myMap))


org.apache.spark.SparkException: Job aborted due to stage failure: Task 8 in stage 3.0 failed 4 times, most recent failure: Lost task 8.3 in stage 3.0 (TID 118, vmc0251):
java.lang.NoClassDefFoundError: com/twitter/jsr166e/LongAdder
  at com.datastax.spark.connector.metrics.OutputMetricsUpdater$TaskMetricsSupport$class.$init$(OutputMetricsUpdater.scala:107)
  at com.datastax.spark.connector.metrics.OutputMetricsUpdater$TaskMetricsUpdater.<init>(OutputMetricsUpdater.scala:146)
  at com.datastax.spark.connector.metrics.OutputMetricsUpdater$.apply(OutputMetricsUpdater.scala:76)
  at com.datastax.spark.connector.writer.TableWriter.write(TableWriter.scala:119)
  at com.datastax.spark.connector.RDDFunctions$$anonfun$saveToCassandra$1.apply(RDDFunctions.scala:36)
  at com.datastax.spark.connector.RDDFunctions$$anonfun$saveToCassandra$1.apply(RDDFunctions.scala:36)
  at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:61)
  at org.apache.spark.executor.Executor$
  at java.util.concurrent.ThreadPoolExecutor.runWorker(
  at java.util.concurrent.ThreadPoolExecutor$
Caused by: java.lang.ClassNotFoundException: com.twitter.jsr166e.LongAdder
  at Method)
  at java.lang.ClassLoader.loadClass(
  at sun.misc.Launcher$AppClassLoader.loadClass(
  at java.lang.ClassLoader.loadClass(
  ... 12 more Driver stacktrace:

Please help us on that issue.



10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

The exception you posted is usually caused misconfiguration where the connector or its dependencies are not in the classpath.

You need to use the --packages method to add the connector + dependencies to the runtime classpath. Otherwise, you need to check that your app is correctly configured as described in the spark-cassandra-connector FAQ. Cheers!

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.