com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table schema_keyspaces

2022-09-01 17:36:10

我正在尝试使用cassandra配置弹簧数据。但是我得到了波纹管错误,当我的应用程序在tomcat中部署时。

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

全栈跟踪:

2015-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>

答案 1

问题是Spring Data Cassandra(截至2015年12月,当我写这篇文章时)没有为Cassandra 3.x提供支持。以下是在freenode上与#spring频道中的一位开发人员的对话摘录:

[13:49] <_amicable>大家好,有谁知道弹簧数据Cassandra是否支持cassandra 3.x?所有依赖项和 datastax 驱动程序似乎都是 2.x

[13:49] <@_ollie>友好:在不久的将来不会。

[13:49] <_amicable> _ollie:谢谢。

[13:50] <_amicable>我去看看2.x与3.x的相对优点,然后;)

[13:51] <@_ollie>SD Cassandra是一个社区项目(到目前为止),它的进展很大程度上取决于开发人员实际上可以花多少时间。

[13:51] <@_ollie>我们将在2016年2月有人加入团队,以使该项目与Spring Data的核心项目更加紧密地保持一致。


答案 2

看起来您正在使用带有Cassandra 3.0的旧版本的驱动程序。Cassandra 3.0 更改了其内部架构元数据表示形式,只有最新的驱动程序才能解析此元数据。

使用 Java Cassandra 驱动程序 3.0.0-alpha5 连接到 Cassandra 3.0。


推荐