一尘不染

com.datastax.driver.core.exceptions.InvalidQueryException:未配置的表schema_keyspaces

spring

我正在尝试使用cassandra配置spring数据。但是当我的应用程序在tomcat中部署时,出现了以下错误。

当我检查连接时,它可用于给定的端口。(127.0.0.1:9042)。我包括波纹管堆栈跟踪和弹簧配置。有人对此错误有想法吗?

完整堆栈跟踪:

2019-12-06 17:46:25 ERROR web.context.ContextLoader:331 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession': Invocation of init method failed; nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table schema_keyspaces))
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1572)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:759)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1245)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1895)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table schema_keyspaces))
    at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:223)
    at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:78)
    at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1230)
    at com.datastax.driver.core.Cluster.init(Cluster.java:157)
    at com.datastax.driver.core.Cluster.connect(Cluster.java:245)
    at com.datastax.driver.core.Cluster.connect(Cluster.java:278)
    at org.springframework.cassandra.config.CassandraCqlSessionFactoryBean.afterPropertiesSet(CassandraCqlSessionFactoryBean.java:82)
    at org.springframework.data.cassandra.config.CassandraSessionFactoryBean.afterPropertiesSet(CassandraSessionFactoryBean.java:43)

================================================== =================

弹簧配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans ...>

    <cassandra:cluster id="cassandraCluster"
                       contact-points="127.0.0.1" port="9042" />
    <cassandra:converter />

    <cassandra:session id="cassandraSession" cluster-ref="cassandraCluster"
                       keyspace-name="blood" />

    <cassandra:template id="cqlTemplate" />


    <cassandra:repositories base-package="com.blood.dao.nosql" />
    <cassandra:mapping entity-base-packages="com.blood.domain.nosql" />

</beans:beans>

阅读 632

收藏
2020-04-18

共1个答案

一尘不染

问题是Spring Data Cassandra不提供对Cassandra 3.x的支持。这是在freenode上#spring频道中与一位开发人员的对话的摘录:

`[13:49] <_amicable> Hi all, does anybody know if spring data cassandra supports cassandra 3.x? All dependencies & datastax drivers seem to be 2.x

[13:49] @_ollie amicable: Not in the near future.

[13:49] <_amicable> _ollie: thanks.

[13:50] <_amicable> I’ll go and look at the relative merits of 2.x vs 3.x then ;)

[13:51] @_ollie SD Cassandra is a community project (so far) and its progress highly depends on how much time the developers can actually spend on it.

[13:51] @_ollie We will have someone joining the team in February 2016 to get the project more closely aligned to the core Spring Data projects.`

2020-04-18