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

时间:2015-12-06 12:24:31

标签: java spring cassandra spring-data datastax

我正在尝试使用cassandra配置spring数据。 但是当我的应用程序在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)

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

Spring配置:

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

2 个答案:

答案 0 :(得分:24)

问题是Spring Data Cassandra(截至2015年12月,当我写这篇文章时)不支持Cassandra 3.x.这是与freenode上#spring频道中的一位开发者的对话摘录:

  

[13:49]&lt; _amicable&gt;大家好,有人知道春天数据cassandra是否支持cassandra 3.x?所有依赖关系&amp; datastax驱动程序似乎是2.x

     

[13:49]&lt; @_ ollie&gt;友好的:不是在不久的将来。

     

[13:49]&lt; _amicable&gt; _ollie:谢谢。

     

[13:50]&lt; _amicable&gt;我会去看看2.x vs 3.x的相对优点   ;)

     

[13:51]&lt; @_ ollie&gt; SD Cassandra是一个社区项目(到目前为止),其进展在很大程度上取决于开发人员实际花费多少时间。

     

[13:51]&lt; @_ ollie&gt;我们将在2016年2月加入团队,以使项目更紧密地与核心Spring Data项目保持一致。

答案 1 :(得分:5)

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

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