Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cassandraSessionFactory' defined in class path resource [com/test/config/CassandraConfig.class]: Unsatisfied dependency expressed through method 'cassandraSessionFactory' parameter 0: Error creating bean with name 'cassandraSession' defined in class path resource [com/test/config/CassandraConfig.class]: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=cassandra/<unresolved>:9042, hostId=null, hashCode=65654666): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-6.0.10.jar!/:6.0.10]
at
@Bean
public CqlSessionFactoryBean cassandraSession() {
CqlSessionFactoryBean session = new CqlSessionFactoryBean();
session.setContactPoints("cassandra");
session.setKeyspaceCreations(getKeyspaceCreations());
session.setKeyspaceName(keySpace);
session.setPort(port);
session.setUsername(userName);
session.setPassword(password);
session.setLocalDatacenter(datacenter);
session.setSessionBuilderConfigurer(sessionBuilder -> sessionBuilder
.withConfigLoader(DriverConfigLoader
.programmaticBuilder()
.withString(DefaultDriverOption.REQUEST_TIMEOUT, "10 seconds")
.build()));
return session;
}
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<version>4.1.3</version>
</dependency>
Its not due to any version mismatch , I found that there is time difference on cluster worker nodes due to which cassandra gosips are created and sync isn't created between cassandra nodes
Once worker nodes time is synced 4.1.3 version of cassandra came up and running without any data loss