错误/异常不一致,找不到请求操作的编解码器:[float< - > java.lang.Object]和[int< - > java.lang.Object继承]

时间:2016-12-27 13:43:21

标签: cassandra annotations guava datastax-java-driver

我正在尝试使用下面的stacktrace进行CodecNotFoundException 使用datastax java驱动程序的注释插入数据,以便与cassandra进行映射。

例外1 ::

Exception in thread "main" com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [float <-> java.lang.Object]
    at com.datastax.driver.core.exceptions.CodecNotFoundException.copy(CodecNotFoundException.java:56)
    at com.datastax.driver.core.exceptions.CodecNotFoundException.copy(CodecNotFoundException.java:25)
    at com.datastax.driver.mapping.DriverThrowables.propagateCause(DriverThrowables.java:41)
    at com.datastax.driver.mapping.Mapper.save(Mapper.java:275)
    at com.coreanalytics.componentConfig.ChartConfigInteraction.saveChartConf(ChartConfigInteraction.scala:14)
    at com.coreanalytics.componentConfig.testing$.delayedEndpoint$com$coreanalytics$componentConfig$testing$1(ChartConfigInteraction.scala:23)
    at com.coreanalytics.componentConfig.testing$delayedInit$body.apply(ChartConfigInteraction.scala:18)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
    at scala.App$class.main(App.scala:76)
    at com.coreanalytics.componentConfig.testing$.main(ChartConfigInteraction.scala:18)
    at com.coreanalytics.componentConfig.testing.main(ChartConfigInteraction.scala)

例外2 ::

Exception in thread "main" com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [int <-> java.lang.Object]
    at com.datastax.driver.core.exceptions.CodecNotFoundException.copy(CodecNotFoundException.java:56)
    at com.datastax.driver.core.exceptions.CodecNotFoundException.copy(CodecNotFoundException.java:25)
    at com.datastax.driver.mapping.DriverThrowables.propagateCause(DriverThrowables.java:41)
    at com.datastax.driver.mapping.Mapper.save(Mapper.java:275)
    at com.coreanalytics.componentConfig.ChartConfigInteraction.saveChartConf(ChartConfigInteraction.scala:14)
    at com.coreanalytics.componentConfig.testing$.delayedEndpoint$com$coreanalytics$componentConfig$testing$1(ChartConfigInteraction.scala:23)
    at com.coreanalytics.componentConfig.testing$delayedInit$body.apply(ChartConfigInteraction.scala:18)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
    at scala.App$class.main(App.scala:76)
    at com.coreanalytics.componentConfig.testing$.main(ChartConfigInteraction.scala:18)
    at com.coreanalytics.componentConfig.testing.main(ChartConfigInteraction.scala)

问题是我在尝试执行相同的代码时遇到了这两个不同的异常。 (相同的表,相同的插入操作,没有变化)(例如,对于第一次执行,我得到float的异常,而不是第二次或第三次我得到int一个) 我已经两次检查了我的表,它似乎没有类型的问题,但是为什么我得到这个例外?

由于我的表有大约50列,大约有8个UDT,因此很难在这里显示整个模式。我还验证了UDTs字段类型与bean&#39;属性。而且,我正在使用Scala做所有这些事情。

注意:我已尝试更新Guava依赖项,但它在FutureCallBack中存在问题,因为它已被删除。

2 个答案:

答案 0 :(得分:0)

在我看来,这是一个简单的&#34;绑定&#34;问题。正如错误清楚地说明的那样,您将int / float字段绑定到对象,并且驱动程序无法进行关联,因为它不知道如何执行该操作。

修复很简单,您必须确保每个CF在应用程序级别完成其关联。

如果您无法理解何时失败,请将您的表定义放在此处(即使它很大),并记住在此处发布将数据绑定到列的代码。

答案 1 :(得分:0)