首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Kundera在Cassandra中持久化数据

无法使用Kundera在Cassandra中持久化数据
EN

Stack Overflow用户
提问于 2015-06-29 17:46:15
回答 2查看 415关注 0票数 1

我尝试连接到cassadra并从this link执行CRUD操作。但是在执行完代码后,得到了下面的异常。找不到这个问题。

代码语言:javascript
复制
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Jun 29, 2015 2:47:00 PM com.impetus.client.cassandra.config.CassandraPropertyReader onProperties
WARNING: No property file found in class path, kundera will use default property
Jun 29, 2015 2:47:01 PM com.impetus.kundera.persistence.EntityManagerFactoryImpl <init>
INFO: EntityManagerFactory created for persistence unit : kundera
Exception in thread "main" com.impetus.kundera.KunderaException: org.scale7.cassandra.pelops.exceptions.NoConnectionsAvailableException: Failed to get a connection within the configured max wait time.
    at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:208)
    at kundera.KunderaClient.main(KunderaClient.java:22)
Caused by: org.scale7.cassandra.pelops.exceptions.NoConnectionsAvailableException: Failed to get a connection within the configured max wait time.
    at org.scale7.cassandra.pelops.pool.CommonsBackedPool.getConnectionExcept(CommonsBackedPool.java:345)
    at org.scale7.cassandra.pelops.Operand.tryOperation(Operand.java:77)
    at org.scale7.cassandra.pelops.Mutator.execute(Mutator.java:93)
    at org.scale7.cassandra.pelops.Mutator.execute(Mutator.java:63)
    at com.impetus.client.cassandra.pelops.PelopsClient.onPersist(PelopsClient.java:527)
    at com.impetus.kundera.client.ClientBase.persist(ClientBase.java:83)
    at com.impetus.kundera.lifecycle.states.ManagedState.handleFlush(ManagedState.java:193)
    at com.impetus.kundera.graph.Node.flush(Node.java:525)
    at com.impetus.kundera.persistence.PersistenceDelegator.flush(PersistenceDelegator.java:411)
    at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:169)
    at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:202)
    ... 1 more

但是,我可以从cqlsh执行crud操作。

下面是我的persistence.xml文件:

代码语言:javascript
复制
    <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
    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 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="kundera">
        <provider>com.impetus.kundera.KunderaPersistence</provider>
        <class>kundera.Catalog</class>
        <properties>
            <property name="kundera.nodes" value="localhost" />
            <property name="kundera.port" value="9042" />
            <property name="kundera.username" value="cassandra" />
            <property name="kundera.passsword" value="cassandra" />
            <property name="kundera.keyspace" value="Kundera" />
            <property name="kundera.dialect" value="cassandra" />
            <property name="kundera.client.lookup.class"
                value="com.impetus.client.cassandra.pelops.PelopsClientFactory" />
            <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>

我尝试将kundera.port更改为9160。但得到了相同的异常。

EN

回答 2

Stack Overflow用户

发布于 2015-06-30 15:05:24

您的Cassandra服务器是否启用了身份验证?您使用的是哪个版本的kundera-cassandra?另外,您是否可以更新您的persistence.xml并尝试:

代码语言:javascript
复制
<persistence-unit name="kundera">
    <provider>com.impetus.kundera.KunderaPersistence</provider>
    <class>kundera.Catalog</class>
    <properties>
        <property name="kundera.nodes" value="localhost" />
        <property name="kundera.port" value="9160" />
        <property name="kundera.username" value="cassandra" />
        <property name="kundera.passsword" value="cassandra" />
        <property name="kundera.keyspace" value="Kundera" />
        <property name="kundera.dialect" value="cassandra" />
        <property name="kundera.client.lookup.class"
            value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />

    </properties>
</persistence-unit>

票数 0
EN

Stack Overflow用户

发布于 2015-07-05 01:52:17

9042端口用于启用cql3二进制协议的客户端,但不适用于thrift客户端。变化,

<property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.pelops.PelopsClientFactory" />

<property name="kundera.client.lookup.class" value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory" />

这对你来说应该是可行的。

HTH,-Vivek

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31112519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档