无法通过Kundera在Play中连接到Cassandra db!骨架

时间:2015-12-15 14:22:51

标签: scala playframework-2.0 cql cassandra-2.0 kundera

当我在Intellij IDEA中通过SBT控制台运行我的应用程序时出现以下错误。

[info] play - Application started (Dev)
[error] c.i.c.c.t.ThriftClientFactory - Error during pool creation: caused by 
org.apache.thrift.TException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
    at net.dataforte.cassandra.pool.ConnectionPool.init(ConnectionPool.java:345) ~[cassandra-connection-pool-0.7.1.jar:na]
    at net.dataforte.cassandra.pool.ConnectionPool.<init>(ConnectionPool.java:127) ~[cassandra-connection-pool-0.7.1.jar:na]
    at com.impetus.client.cassandra.thrift.ThriftClientFactory.createPoolOrConnection(ThriftClientFactory.java:146) ~[kundera-cassandra-2.5.jar:na]
    at com.impetus.kundera.loader.GenericClientFactory.load(GenericClientFactory.java:95) [kundera-core-2.5.jar:na]
    at com.impetus.kundera.configure.ClientFactoryConfiguraton.configure(ClientFactoryConfiguraton.java:67) [kundera-core-2.5.jar:na]
Caused by: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
    at org.apache.thrift.transport.TFastFramedTransport.readFrame(TFastFramedTransport.java:144) ~[libthrift-0.7.0.jar:0.7.0]
    at org.apache.thrift.transport.TFastFramedTransport.read(TFastFramedTransport.java:134) ~[libthrift-0.7.0.jar:0.7.0]
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84) ~[libthrift-0.7.0.jar:0.7.0]
    at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378) ~[libthrift-0.7.0.jar:0.7.0]
    at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297) ~[libthrift-0.7.0.jar:0.7.0]
[error] application - 

! Internal server error, for (GET) [/] ->

java.lang.ExceptionInInitializerError: null
    at models.process.EmployeeProcessImpl$.<init>(EmployeeProcess.scala:82) ~[myEntities.jar:na]
    at models.process.EmployeeProcessImpl$.<clinit>(EmployeeProcess.scala) ~[myEntities.jar:na]
    at controllers.Application$.<init>(Application.scala:168) ~[na:na]
    at controllers.Application$.<clinit>(Application.scala) ~[na:na]
    at Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(routes_routing.scala:107) ~[na:na]
Caused by: com.impetus.kundera.loader.ClientLoaderException: org.apache.thrift.TException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
    at com.impetus.client.cassandra.thrift.ThriftClientFactory.createPoolOrConnection(ThriftClientFactory.java:151) ~[kundera-cassandra-2.5.jar:na]
    at com.impetus.kundera.loader.GenericClientFactory.load(GenericClientFactory.java:95) ~[kundera-core-2.5.jar:na]
    at com.impetus.kundera.configure.ClientFactoryConfiguraton.configure(ClientFactoryConfiguraton.java:67) ~[kundera-core-2.5.jar:na]
    at com.impetus.kundera.configure.Configurator.configure(Configurator.java:65) ~[kundera-core-2.5.jar:na]
    at com.impetus.kundera.KunderaPersistence.initializeKundera(KunderaPersistence.java:109) ~[kundera-core-2.5.jar:na]
Caused by: org.apache.thrift.TException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
    at net.dataforte.cassandra.pool.ConnectionPool.init(ConnectionPool.java:345) ~[cassandra-connection-pool-0.7.1.jar:na]
    at net.dataforte.cassandra.pool.ConnectionPool.<init>(ConnectionPool.java:127) ~[cassandra-connection-pool-0.7.1.jar:na]
    at com.impetus.client.cassandra.thrift.ThriftClientFactory.createPoolOrConnection(ThriftClientFactory.java:146) ~[kundera-cassandra-2.5.jar:na]
    at com.impetus.kundera.loader.GenericClientFactory.load(GenericClientFactory.java:95) ~[kundera-core-2.5.jar:na]
    at com.impetus.kundera.configure.ClientFactoryConfiguraton.configure(ClientFactoryConfiguraton.java:67) ~[kundera-core-2.5.jar:na]
Caused by: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
    at org.apache.thrift.transport.TFastFramedTransport.readFrame(TFastFramedTransport.java:144) ~[libthrift-0.7.0.jar:0.7.0]
    at org.apache.thrift.transport.TFastFramedTransport.read(TFastFramedTransport.java:134) ~[libthrift-0.7.0.jar:0.7.0]
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84) ~[libthrift-0.7.0.jar:0.7.0]
    at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378) ~[libthrift-0.7.0.jar:0.7.0]
    at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297) ~[libthrift-0.7.0.jar:0.7.0]
[error] application - Error while rendering default error page
scala.MatchError: java.lang.ExceptionInInitializerError (of class java.lang.ExceptionInInitializerError)
    at play.api.GlobalSettings$class.onError(GlobalSettings.scala:148) ~[play_2.11-2.3.0.jar:2.3.0]
    at play.api.DefaultGlobal$.onError(GlobalSettings.scala:206) [play_2.11-2.3.0.jar:2.3.0]
    at play.core.server.Server$class.logExceptionAndGetResult$1(Server.scala:76) [play_2.11-2.3.0.jar:2.3.0]
    at play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:86) [play_2.11-2.3.0.jar:2.3.0]
    at play.core.server.Server$$anonfun$getHandlerFor$4.apply(Server.scala:84) [play_2.11-2.3.0.jar:2.3.0]

我正在使用的示例取自: Drawing fixed set of grid lines with opencv

我正在玩! 2.4.6框架与Cassandra 2.2。不允许连接数据库的项目有什么问题?我是否需要对CQL或Kundera版本进行一些更改,以便我的数据库可以连接?我的persistence.xml文件如下:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    https://raw.github.com/impetus-opensource/Kundera/Kundera-2.0.4/kundera-core/src/test/resources/META-INF/persistence_2_0.xsd"
    version="2.0">

    <persistence-unit name="cassandra_employees">
        <provider>com.impetus.kundera.KunderaPersistence</provider>
        <class>models.domains.Employee</class>
        <properties>
            <property name="kundera.nodes" value="localhost" />
            <property name="kundera.port" value="9042" />
            <property name="kundera.keyspace" value="EmployeeExample" />
            <property name="kundera.dialect" value="cassandra" />
            <property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
            <property name="kundera.cache.provider.class" value="com.impetus.kundera.cache.ehcache.EhCacheProvider" />
            <property name="kundera.cache.config.resource" value="/ehcache-test.xml" />
        </properties>
    </persistence-unit>

</persistence>

请告诉我是否必须为Cassandra或CQL进行与版本相关的更改以及在哪个文件中进行更改?

1 个答案:

答案 0 :(得分:0)

在config下方使用,它在我的系统上运行正常..

更新了cassandra.yaml:
从: start_rpc:false
至: start_rpc:true

的persistence.xml:
下面提到的单位名称是随机的,将用于访问此特定持久性。
keyspace name是在cassandra中创建的表的名称。

<persistence-unit name="persistence">
        <provider>com.impetus.kundera.KunderaPersistence</provider>
        <properties>
            <property name="kundera.nodes" value="localhost" />
            <property name="kundera.port" value="9160" />
            <property name="kundera.keyspace" value="trial1" />
            <property name="kundera.dialect" value="cassandra" />
                <property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />

            <property name="kundera.pool.size.max.active" value="500" />
            <property name="kundera.pool.size.max.total" value="500" />
        </properties>