title: Spark: IllegalArgumentException: 'Unsupported class file major version 55'
body: <p>Getting the error when running <code>.toPandas()</code>, I've tried the solution mentioned in <a href="https://stackoverflow.com/questions/53583199/pyspark-error-unsupported-class-file-major-version-55">Pyspark error - Unsupported class file major version 55</a> and <a href="https://stackoverflow.com/questions/53989432/pyspark-topandas-unsupported-class-file-major-version-55">Pyspark .toPandas(): &#39;Unsupported class file major version 55&#39;</a> but without success. </p>
  
  <p>I.e., as of now, my .bash_profile looks like:</p>
  
  <pre><code>...
  export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
  ...
  </code></pre>
  
  <p>And running <code>java -version</code> in terminal gives:</p>
  
  <pre><code>java version "1.8.0_201"
  Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
  Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
  </code></pre>
  
  <p>Full error log:</p>
  
  <pre><code>Py4JJavaError: An error occurred while calling o49.collectToPython.
  : java.lang.IllegalArgumentException: Unsupported class file major version 55
      at org.apache.xbean.asm6.ClassReader.&lt;init&gt;(ClassReader.java:166)
      at org.apache.xbean.asm6.ClassReader.&lt;init&gt;(ClassReader.java:148)
      at org.apache.xbean.asm6.ClassReader.&lt;init&gt;(ClassReader.java:136)
      at org.apache.xbean.asm6.ClassReader.&lt;init&gt;(ClassReader.java:237)
      at org.apache.spark.util.ClosureCleaner$.getClassReader(ClosureCleaner.scala:49)
      at org.apache.spark.util.FieldAccessFinder$$anon$3$$anonfun$visitMethodInsn$2.apply(ClosureCleaner.scala:517)
      at org.apache.spark.util.FieldAccessFinder$$anon$3$$anonfun$visitMethodInsn$2.apply(ClosureCleaner.scala:500)
      at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:733)
      at scala.collection.mutable.HashMap$$anon$1$$anonfun$foreach$2.apply(HashMap.scala:134)
      at scala.collection.mutable.HashMap$$anon$1$$anonfun$foreach$2.apply(HashMap.scala:134)
      at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:236)
      at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
      at scala.collection.mutable.HashMap$$anon$1.foreach(HashMap.scala:134)
      at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:732)
      at org.apache.spark.util.FieldAccessFinder$$anon$3.visitMethodInsn(ClosureCleaner.scala:500)
      at org.apache.xbean.asm6.ClassReader.readCode(ClassReader.java:2175)
      at org.apache.xbean.asm6.ClassReader.readMethod(ClassReader.java:1238)
      at org.apache.xbean.asm6.ClassReader.accept(ClassReader.java:631)
      at org.apache.xbean.asm6.ClassReader.accept(ClassReader.java:355)
      at org.apache.spark.util.ClosureCleaner$$anonfun$org$apache$spark$util$ClosureCleaner$$clean$14.apply(ClosureCleaner.scala:307)
      at org.apache.spark.util.ClosureCleaner$$anonfun$org$apache$spark$util$ClosureCleaner$$clean$14.apply(ClosureCleaner.scala:306)
      at scala.collection.immutable.List.foreach(List.scala:392)
      at org.apache.spark.util.ClosureCleaner$.org$apache$spark$util$ClosureCleaner$$clean(ClosureCleaner.scala:306)
      at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:162)
      at org.apache.spark.SparkContext.clean(SparkContext.scala:2326)
      at org.apache.spark.SparkContext.runJob(SparkContext.scala:2100)
      at org.apache.spark.SparkContext.runJob(SparkContext.scala:2126)
      at org.apache.spark.rdd.RDD$$anonfun$collect$1.apply(RDD.scala:945)
      at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
      at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
      at org.apache.spark.rdd.RDD.withScope(RDD.scala:363)
      at org.apache.spark.rdd.RDD.collect(RDD.scala:944)
      at org.apache.spark.sql.execution.SparkPlan.executeCollect(SparkPlan.scala:299)
      at org.apache.spark.sql.Dataset$$anonfun$collectToPython$1.apply(Dataset.scala:3258)
      at org.apache.spark.sql.Dataset$$anonfun$collectToPython$1.apply(Dataset.scala:3255)
      at org.apache.spark.sql.Dataset$$anonfun$53.apply(Dataset.scala:3365)
      at org.apache.spark.sql.execution.SQLExecution$$anonfun$withNewExecutionId$1.apply(SQLExecution.scala:78)
      at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:125)
      at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:73)
      at org.apache.spark.sql.Dataset.withAction(Dataset.scala:3364)
      at org.apache.spark.sql.Dataset.collectToPython(Dataset.scala:3255)
      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:566)
      at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
      at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
      at py4j.Gateway.invoke(Gateway.java:282)
      at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
      at py4j.commands.CallCommand.execute(CallCommand.java:79)
      at py4j.GatewayConnection.run(GatewayConnection.java:238)
      at java.base/java.lang.Thread.run(Thread.java:834)
  
  
  During handling of the above exception, another exception occurred:
  
  IllegalArgumentException                  Traceback (most recent call last)
  &lt;ipython-input-3-198b8ee6e584&gt; in &lt;module&gt;()
        1 df3 = df2.select('col').na.drop()
  ----&gt; 2 print(df3.toPandas())
        3 #print(df3.rdd.flatMap(lambda x: x).toPandas())
  
  /usr/local/spark/python/pyspark/sql/dataframe.py in toPandas(self)
     2140 
     2141         # Below is toPandas without Arrow optimization.
  -&gt; 2142         pdf = pd.DataFrame.from_records(self.collect(), columns=self.columns)
     2143 
     2144         dtype = {}
  
  /usr/local/spark/python/pyspark/sql/dataframe.py in collect(self)
      531         """
      532         with SCCallSiteSync(self._sc) as css:
  --&gt; 533             sock_info = self._jdf.collectToPython()
      534         return list(_load_from_socket(sock_info, BatchedSerializer(PickleSerializer())))
      535 
  
  ~/anaconda3/envs/en_env/lib/python3.5/site-packages/py4j/java_gateway.py in __call__(self, *args)
     1255         answer = self.gateway_client.send_command(command)
     1256         return_value = get_return_value(
  -&gt; 1257             answer, self.gateway_client, self.target_id, self.name)
     1258 
     1259         for temp_arg in temp_args:
  
  /usr/local/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
       77                 raise QueryExecutionException(s.split(': ', 1)[1], stackTrace)
       78             if s.startswith('java.lang.IllegalArgumentException: '):
  ---&gt; 79                 raise IllegalArgumentException(s.split(': ', 1)[1], stackTrace)
       80             raise
       81     return deco
  
  IllegalArgumentException: 'Unsupported class file major version 55'
  </code></pre>