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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34117374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 15:20:36  来源:igfitidea点击:

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

javaspringcassandraspring-datadatastax

提问by Harsha

I am trying to configure spring data with cassandra. But I am getting bellow error , when my app is deploying in tomcat.

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

When I check the connection, it is available to the given port. (127.0.0.1:9042). I have include stack trace and spring configuration bellow. Does anyone having idea on this error?

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

Full stack trace :

完整堆栈跟踪:

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.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)

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

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

Spring Configuration :

弹簧配置:

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

采纳答案by Will Faithfull

The problem is that Spring Data Cassandra (as of December 2015 when I write this) does not provide support for Cassandra 3.x. Here's an excerpt from a conversation with one of the developers in the #spring channel on freenode:

问题是 Spring Data Cassandra(截至 2015 年 12 月我写这篇文章时)不提供对 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.

[13:49] <_amicable> 大家好,有谁知道spring data 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 项目更加紧密地结合。

回答by Adam Holmberg

It looks like you are using an older version of the driver with Cassandra 3.0. Cassandra 3.0 changed its internal schema metadata representation, and only the latest drivers can parse this metadata.

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

Use Java Cassandra driver 3.0.0-alpha5to connect to Cassandra 3.0.

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