运行 使用 Spark 和 Maven 的项目
Run project with Spark and maven
我正在尝试 运行 我的 class java 读取 GML 文件,我为此使用了 Tinkerpop 和 GMLReader,问题是当我尝试 运行 它与 spark 它给了我一个例外
我写了一个简单的测试代码:
public static void main(String[] args) throws IOException {
TinkerGraph graphs = new TinkerGraph();
String in = "/home/salma/Desktop/celegansneural.gml";
GMLReader.inputGraph(graphs, in);
System.out.println(graphs);
}
我用来 运行 class 的命令:
root@salma-SATELLITE-C855-1EQ:/usr/local/spark# ./bin/spark-submit --class graph_example.WordCount --master local[2] ~/workspace/graph_example/target/graph_example-0.0.1-SNAPSHOT.jar
错误:
Exception in thread "main" java.lang.NoClassDefFoundError:
com/tinkerpop/blueprints/impls/tg/TinkerGraph
at graph_example.WordCount.main(WordCount.java:51)
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.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:569)
at org.apache.spark.deploy.SparkSubmit$.doRunMain(SparkSubmit.scala:166)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:189)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:110)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.ClassNotFoundException: com.tinkerpop.blueprints.impls.tg.TinkerGraph
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 10 more
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
您必须提供包含 TinkerGraph 实现的依赖项。
如果我没记错的话,你需要提供this jar
然后你 运行 spark-submit
像往常一样但是 --jars /some/location/blueprints-core-2.6.0.jar
在official documentation中有说明:
When using spark-submit, the application jar along with any jars
included with the --jars option will be automatically transferred to
the cluster.
我正在尝试 运行 我的 class java 读取 GML 文件,我为此使用了 Tinkerpop 和 GMLReader,问题是当我尝试 运行 它与 spark 它给了我一个例外
我写了一个简单的测试代码:
public static void main(String[] args) throws IOException {
TinkerGraph graphs = new TinkerGraph();
String in = "/home/salma/Desktop/celegansneural.gml";
GMLReader.inputGraph(graphs, in);
System.out.println(graphs);
}
我用来 运行 class 的命令:
root@salma-SATELLITE-C855-1EQ:/usr/local/spark# ./bin/spark-submit --class graph_example.WordCount --master local[2] ~/workspace/graph_example/target/graph_example-0.0.1-SNAPSHOT.jar
错误:
Exception in thread "main" java.lang.NoClassDefFoundError:
com/tinkerpop/blueprints/impls/tg/TinkerGraph
at graph_example.WordCount.main(WordCount.java:51)
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.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:569)
at org.apache.spark.deploy.SparkSubmit$.doRunMain(SparkSubmit.scala:166)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:189)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:110)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.ClassNotFoundException: com.tinkerpop.blueprints.impls.tg.TinkerGraph
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 10 more
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
您必须提供包含 TinkerGraph 实现的依赖项。 如果我没记错的话,你需要提供this jar
然后你 运行 spark-submit
像往常一样但是 --jars /some/location/blueprints-core-2.6.0.jar
在official documentation中有说明:
When using spark-submit, the application jar along with any jars included with the --jars option will be automatically transferred to the cluster.