jAvA
jAvA

Reputation: 583

cassandra error keyspace does not exist

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'JournalActions': Invocation of init method failed; nested exception is com.datastax.driver.core.exceptions.InvalidQueryException: Keyspace 'audit' does not exist
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
    at com.paypal.pps.activity.init.RaptorApplication.main(RaptorApplication.java:23)
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: Keyspace 'audit' does not exist

But when i manually login to cqlsh , i'm able to select the table.

cqlsh:journal> use audit;

cqlsh:audit> select * from event_log;

event_id | event_type


i'm using Cassandra 3.9 running on a docker

Upvotes: 3

Views: 11072

Answers (1)

Clement Amarnath
Clement Amarnath

Reputation: 5466

You have already narrowed down the problem(in cqlsh the queries are working), so the problem is on the driver side.

Please ensure the following

1) Driver used (datastax.cassandra - cassandra-driver-core - version 3.0.0-alpha5) is compatible with Cassandra DB Version

2) Remove if you have any spring-data-cassandra libraries reference in your project

Please Refer these posts for more info

https://docs.datastax.com/en/developer/driver-matrix/doc/javaDrivers.html#java-drivers

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

Upvotes: 2

Related Questions