为什么Phantom Cassandra插入会获得“ main” java.lang.NoClassDefFoundError:scala / reflect / runtime / package错误

时间:2019-03-14 10:19:07

标签: scala cassandra phantom-dsl

我对phantom非常陌生,并且对scala和cassandra有基本的了解。所以我试图使用幻像做一个简单的例子,所以我看看谷歌的几个例子。最后,我以this为例。但是我运行的代码与项目自述文件中所说的不一样。我只是创建一个intellij项目,并且有如下的主类。

import org.creative.document.dao.impl.{PhantomConnectorExample}
import org.creative.document.database.SongsDatabase
import org.creative.document.entity.Song

object DocumentAPIMain {

   def main(args: Array[String]): Unit = {

      val song = Song(songId,"Wahinnta Athnam gigum di","Pawana","Nanda Malini")

      val songsDatabase = new SongsDatabase(PhantomConnectorExample.connector)
      songsDatabase.saveOrUpdate(song)

   }

}

那是我唯一要做的事情,除了上面提到的所有依赖项和其他所有链接。

我已经手动创建了cassandra键空间,songs表和songs_by_artist表。以下是显示我的卡桑德拉·谢马

CREATE KEYSPACE phantomtest WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}  AND durable_writes = true;

CREATE TABLE phantomtest.songs_by_artist (
artist text,
id timeuuid,
album text,
title text,
PRIMARY KEY (artist, id)
) WITH CLUSTERING ORDER BY (id ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

CREATE TABLE phantomtest.songs (
id timeuuid PRIMARY KEY,
album text,
artist text,
title text
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

毕竟,当我运行我的main方法时,它将最终出现以下错误

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/runtime/package$
at com.outworkers.phantom.column.AbstractColumn.com$outworkers$phantom$column$AbstractColumn$$_name(AbstractColumn.scala:55)
at com.outworkers.phantom.column.AbstractColumn.com$outworkers$phantom$column$AbstractColumn$$_name$(AbstractColumn.scala:54)
at com.outworkers.phantom.column.Column.com$outworkers$phantom$column$AbstractColumn$$_name$lzycompute(Column.scala:22)
at com.outworkers.phantom.column.Column.com$outworkers$phantom$column$AbstractColumn$$_name(Column.scala:22)
at com.outworkers.phantom.column.AbstractColumn.name(AbstractColumn.scala:58)
at com.outworkers.phantom.column.AbstractColumn.name$(AbstractColumn.scala:58)
at com.outworkers.phantom.column.Column.name(Column.scala:22)
at org.creative.document.database.SongsDatabase$anon$macro$1$1.store(SongsDatabase.scala:28)
at org.creative.document.database.SongsDatabase$anon$macro$1$1.store(SongsDatabase.scala:28)
at com.outworkers.phantom.CassandraTable.store(CassandraTable.scala:132)
at org.creative.document.database.SongsDatabase.saveOrUpdate(SongsDatabase.scala:28)
at org.creative.document.main.DocumentAPIMain$.main(DocumentAPIMain.scala:58)
at org.creative.document.main.DocumentAPIMain.main(DocumentAPIMain.scala)
Caused by: java.lang.ClassNotFoundException: scala.reflect.runtime.package$
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more

请帮助我找出问题所在。我做错了什么...

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并添加了以下依赖性。

df["UTC"] = pd.to_datetime(df["UnixTime"], unit = "s")

对我有用。