2016-12-20 7 views
0

私はT1とT2の時間差を計算しようとしています。 スパーク・シェルで私のコードは以下の通りです:Sparkのnscala_timeで時間差を計算する方法

scala> import com.github.nscala_time.time.Imports._ 
import com.github.nscala_time.time.Imports._ 
scala> import org.joda.time.DateTime 
import org.joda.time.DateTime 

scala> val T1 = DateTime.parse("2014-10-12T10:32:32") 
T1: org.joda.time.DateTime = 2014-10-12T10:32:32.000+08:00 
scala> val T2 = DateTime.parse("2014-10-12T10:33:32") 
T2: org.joda.time.DateTime = 2014-10-12T10:33:32.000+08:00 
scala> val diff = (T1 to T2).millis/1000 
diff: Long = 60 

すべてが正常に動作します。 は、だから私のsbtと火花提出同じコード: enter image description here

私の依存関係ファイルは以下の通りです: enter image description here

は、コードを提出する:

spark-shell --class "YourApp" --jars /usr/local/spark/lib_third/nscala-time-master/target/scala-2.10/nscala-time_2.10-2.15.0-SNAPSHOT.jar ~/Spark_nscala2/target/scala-2.10/YourApp_2.10-1.0.jar 

はしかし、それは間違っていた:

Exception in thread "main" java.lang.NoSuchMethodError: com.github.nscala_time.time.Imports$.RichReadableInstant(Lorg/joda/time/ReadableInstant;)Lcom/github/nscala_time/time/RichReadableInstant; 
    at YourApp$.main(YourApp.scala:15) 
    at YourApp.main(YourApp.scala) 

例外はこの文章からの問題を示しています:

val diff = (T1 to T2).millis/1000 

私には意味がありません。同じコードはspark-shellで動作しますが、送信時には失敗します。 問題がどこにあるか教えてもらえますか?ありがとうございます!私はそれを把握myself.Iがnscala_time jarファイルの別のバージョンを試してみましたが、それに応じて、依存関係を変更し

答えて

0

試みは--driverクラスパスをするだけでなく、あなたのサードパーティのjarファイルを追加します問題は修正されました。

+0

nope、同じ古いエラー – Liaoxiaochen