无法运行ALS.train,错误:java.lang.IllegalArgumentException

时间:2018-02-10 09:53:13

标签: apache-spark pyspark apache-spark-mllib

我正在尝试ALS of PySpark。我复制了&粘贴链接中提供的示例代码。但是,错误java.lang.IllegalArgumentException出现在以下行:

model = ALS.train(ratings, rank, numIterations)

请问我需要在这里调查哪些可能存在的问题?

我的Spark版本是2.2.1,我的Java版本是9.0.4。但是,我不确定Spark是否使用了正确版本的Java,尽管我设置了环境路径和命令" java -version"确实返回" 9.0.4"。

错误:

enter image description here

  

Py4JJavaError:调用时发生错误   Z:org.apache.spark.mllib.api.python.SerDe.pythonToJava。 :   java.lang.IllegalArgumentException at   org.apache.xbean.asm5.ClassReader。(未知来源)at   org.apache.xbean.asm5.ClassReader。(未知来源)at   org.apache.xbean.asm5.ClassReader。(未知来源)at   org.apache.spark.util.ClosureCleaner $ .getClassReader(ClosureCleaner.scala:46)   在   org.apache.spark.util.FieldAccessFinder $$不久$ 3 $$ anonfun $ visitMethodInsn $ 2.适用(ClosureCleaner.scala:443)   在   org.apache.spark.util.FieldAccessFinder $$不久$ 3 $$ anonfun $ visitMethodInsn $ 2.适用(ClosureCleaner.scala:426)   在   scala.collection.TraversableLike $ WithFilter $$ anonfun $ $的foreach 1.适用(TraversableLike.scala:733)   在   scala.collection.mutable.HashMap $$匿名$ $$ 1 $ anonfun的foreach $ 2.适用(HashMap.scala:103)   在   scala.collection.mutable.HashMap $$匿名$ $$ 1 $ anonfun的foreach $ 2.适用(HashMap.scala:103)   在   scala.collection.mutable.HashTable $ class.foreachEntry(HashTable.scala:230)   在scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)at at   scala.collection.mutable.HashMap $$ anon $ 1.foreach(HashMap.scala:103)at at   scala.collection.TraversableLike $ WithFilter.foreach(TraversableLike.scala:732)   在   org.apache.spark.util.FieldAccessFinder $$匿名$ 3.visitMethodInsn(ClosureCleaner.scala:426)   在org.apache.xbean.asm5.ClassReader.a(未知来源)at   org.apache.xbean.asm5.ClassReader.b(未知来源)at   org.apache.xbean.asm5.ClassReader.accept(未知来源)at   org.apache.xbean.asm5.ClassReader.accept(未知来源)at   org.apache.spark.util.ClosureCleaner $$ anonfun $ $组织阿帕奇$火花$ UTIL $ ClosureCleaner $$清洁$ 14.apply(ClosureCleaner.scala:257)   在   org.apache.spark.util.ClosureCleaner $$ anonfun $ $组织阿帕奇$火花$ UTIL $ ClosureCleaner $$清洁$ 14.apply(ClosureCleaner.scala:256)   在scala.collection.immutable.List.foreach(List.scala:381)at   org.apache.spark.util.ClosureCleaner $ .ORG $阿帕奇$火花$ UTIL $ ClosureCleaner $$干净(ClosureCleaner.scala:256)   在   org.apache.spark.util.ClosureCleaner $清洁机壳(ClosureCleaner.scala:156)   在org.apache.spark.SparkContext.clean(SparkContext.scala:2294)at   org.apache.spark.rdd.RDD $$ anonfun $ mapPartitions $ 1.适用(RDD.scala:794)   在   org.apache.spark.rdd.RDD $$ anonfun $ mapPartitions $ 1.适用(RDD.scala:793)   在   org.apache.spark.rdd.RDDOperationScope $ .withScope(RDDOperationScope.scala:151)   在   org.apache.spark.rdd.RDDOperationScope $ .withScope(RDDOperationScope.scala:112)   在org.apache.spark.rdd.RDD.withScope(RDD.scala:362)at   org.apache.spark.rdd.RDD.mapPartitions(RDD.scala:793)at at   org.apache.spark.mllib.api.python.SerDeBase.pythonToJava(PythonMLLibAPI.scala:1349)   在   org.apache.spark.mllib.api.python.SerDe.pythonToJava(PythonMLLibAPI.scala)   在jdk.internal.reflect.GeneratedMethodAccessor76.invoke(未知   来源)at   java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   在java.base / java.lang.reflect.Method.invoke(Method.java:564)at   py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)at at   py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)at   py4j.Gateway.invoke(Gateway.java:280)at   py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)   在py4j.commands.CallCommand.execute(CallCommand.java:79)at   py4j.GatewayConnection.run(GatewayConnection.java:214)at   java.base / java.lang.Thread.run(Thread.java:844)

1 个答案:

答案 0 :(得分:2)

我已经找到了问题所在。 Spark 2.2.1不适用于Java 9.0.4。也许我误解了这部分" Java 8 +"教程。

如果有人遇到与我相同的错误,那就去Java 1.8.0吧!