2015-07-11 189 views
2

我得到這個錯誤每次我運行我的Scala程序火花與卡桑德拉連接器火花工作卡桑德拉錯誤

Exception during preparation of SELECT count(*) FROM "eventtest"."simpletbl" WHERE token("a") > ? AND token("a") <= ? 
    ALLOW FILTERING: class org.joda.time.DateTime in JavaMirror with [email protected] of type class org.apache.spark.util.MutableURLClassLoader 
    with classpath 
    [file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/work/app-20150711142923-0023/0/./spark-cassandra-connector_2.10-1.4.0-M1.jar 
    ,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/work/app-20150711142923-0023/0/./cassandra-driver-core-2.1.5.jar,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/work/app-20150711142923-0023/0/./cassandra-spark-job_2.10-1.0.jar,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/work/app-20150711142923-0023/0/./guava-18.0.jar,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/work/app-20150711142923-0023/0/./joda-convert-1.2.jar,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/work/app-20150711142923-0023/0/./cassandra-clientutil-2.1.5.jar,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/work/app-20150711142923-0023/0/./google-collections-1.0.jar] and parent being [email protected] of type class sun.misc.Launcher$AppClassLoader with classpath [file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/conf/,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/lib/spark-assembly-1.4.0-hadoop2.4.0.jar,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/lib/datanucleus-api-jdo-3.2.6.jar,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/lib/datanucleus-core-3.2.10.jar,file: 
    /home/sysadmin/ApacheSpark/spark-1.4.0-bin-hadoop2.4/lib/datanucleus-rdbms-3.2.9.jar] and parent being [email protected] of type class sun.misc.Launcher$ExtClassLoader with classpath [file: 
    /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/dnsns.jar,file: 
    /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunpkcs11.jar,file: 
    /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunjce_provider.jar,file: 
    /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/zipfs.jar,file: 
    /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/libatk-wrapper.so,file: 
    /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar,file: 
    /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/localedata.jar,file: 
    /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/icedtea-sound.jar] and parent being primordial classloader with boot classpath [/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jfr.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/classes] not found. 
     at com.datastax.spark.connector.rdd.CassandraTableScanRDD.createStatement(CassandraTableScanRDD.scala:163) 

這裏是我的程序

 
    /** CassandraJob.scala **/ 

    import com.datastax.spark.connector._ 
    import org.apache.spark._ 


    object CassandraJob { 
      def main(args: Array[String]) { 
        val conf = new SparkConf(true) 
            .set("spark.cassandra.connection.host", "172.28.0.164") 
            .set("soark.cassandra.connection.rpc.port", "9160") 

        val sc = new SparkContext(conf) 
        val rdd = sc.cassandraTable("eventtest", "simpletbl"); 
        println("cassandra row count : " + rdd.count + ", cassanra row : " + rdd.first) 

      } 
    } 

我使用SBT編譯生成文件時,sbt包

這裏是我如何提交點火作業

./bin/spark-submit --jars $(echo /home/sysadmin/ApacheSpark/jar/*.jar | tr ' ' ',') --class "CassandraJob" --master spark://noi-cs-01:7077 /home/sysadmin/ApacheSparkProj/CassandraJob/target/scala-2.10/cassandra-spark-job_2.10-1.0.jar 

回答

3

我想你正在使用org.joda.time.DateTime,它在提交的jar中缺失。就在這個jar添加到您的依賴關係:... --jars $(echo /home/sysadmin/ApacheSpark/jar/*.jar | tr ' ' ','),/PATH/TO/DOWNLOADED/JODATIME/JAR --class "CassandraJob..."

的另一種方式是包括庫的依賴org.joda.time.DateTime在SBT和裝配脂肪罐子使用的sbt assemblyplugin代替sbt package這個庫。