Exception in thread "main" java.lang.NullPointerException一例解决

完整报错信息是:

Exception in thread "main" java.lang.NullPointerException
	at scala.io.Source$.fromURL(Source.scala:141)
	at RunGeoTime$.main(RunGeoTime.scala:66)
	at RunGeoTime.main(RunGeoTime.scala)
	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.JavaMainApplication.start(SparkApplication.scala:52)
	at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:894)
	at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:198)
	at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:228)
	at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:137)
	at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

根据报错信息:

    at RunGeoTime$.main(RunGeoTime.scala:66)

可知在RunGeoTime.scala的第66行

注意,不要在spark里面调试,

另外开个薪的.scala文件,把第66行扔进去,

调试完了再在spark工程里面修改,这样可以节省时间.

最终解决方案:

val geojson = scala.io.Source.fromURL(this.getClass.getResource("hdfs://master:9000/configuration/nyc-boroughs.geojson")).mkString

修改为:
val geojson = scala.io.Source.fromURL("hdfs://master:9000/configuration/nyc-boroughs.geojson").mkString

猜你喜欢

转载自blog.csdn.net/appleyuchi/article/details/89848107