kundera:java.lang.ClassCastException:java.lang.String不能转换为[B

时间:2016-05-10 11:58:12

标签: java hibernate cassandra kundera

我想使用 kundera 框架将对象插入 cassandra ,但我收到此错误:

java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String cannot be cast to [B
        at org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:448) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:414) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:73) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.daemon.executor$fn__8226$fn__8239$fn__8292.invoke(executor.clj:851) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.util$async_loop$fn__554.invoke(util.clj:484) [storm-core-1.0.0.jar:1.0.0]
        at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_99]
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to [B
        at org.apache.storm.tuple.TupleImpl.getBinaryByField(TupleImpl.java:185) ~[storm-core-1.0.0.jar:1.0.0]
        at connector.bolt.PrinterBolt.execute(PrinterBolt.java:59) ~[Zorro-0.0.1-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.apache.storm.daemon.executor$fn__8226$tuple_action_fn__8228.invoke(executor.clj:731) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.daemon.executor$mk_task_receiver$fn__8147.invoke(executor.clj:463) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.disruptor$clojure_handler$reify__7663.onEvent(disruptor.clj:40) ~[storm-core-1.0.0.jar:1.0.0]
        at org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:435) ~[storm-core-1.0.0.jar:1.0.0]
        ... 6 more

我的实体类

@Entity
@Table(name = "pieces", schema = "piece@cassandra_pu")
public class PieceEntitie implements Serializable{

    @Id private String IdPiece;
    @Column private double width;
    @Column private double height;
    @Column private double depth;
    public PieceEntitie() {
        // TODO Auto-generated constructor stub
    }
.
.
.
}

我按照教程:https://github.com/impetus-opensource/Kundera/wiki/Getting-Started-in-5-minutes

您对此问题的根源以及我们如何解决此问题有任何疑问吗? 谢谢

1 个答案:

答案 0 :(得分:0)

使用Storm方法TupleImpl.getBinaryByField()时遇到问题,它会抛出异常,说它无法从byte[]获得String。 Storm元组里面有一些字符串值,你试图获取字节数组。