We are upgrading to Spring boot 2.3.5.RELEASE. Our application has cassandra as one of the databases and we have enabled authentication on the nodes. On trying to connect to the casssandra db after updating the spring boot version, I getting this exception and not able to start up the application.
Authentication error on node <IP:PORT> requires authentication (org.apache.cassandra.auth.PasswordAuthenticator), but no authenticator configured
My cassandra configuration is as follows:
@Configuration
@ConfigurationProperties("spring.data.cassandra.keyspaceName")
@EnableCassandraRepositories(basePackages = { "com.company.project.feature.cassandra.repo" },
cassandraTemplateRef = "dbTemplate")
public class Config extends AbstractCassandraConfiguration {
@Autowired
ServerProperties serverProps;
protected String contactPoints;
protected Integer port;
protected String keyspaceName;
protected String localDataCenter;
@Override
public String getContactPoints() {
return contactPoints;
}
/**
* @param contactPoints
*/
public void setContactPoints(String contactPoints) {
this.contactPoints = contactPoints;
}
/**
* @param keyspaceName
*/
public void setKeyspaceName(String keyspaceName) {
this.keyspaceName = keyspaceName;
}
@Override
public String getKeyspaceName() {
return keyspaceName;
}
@Override
public int getPort() {
return port;
}
public void setLocalDataCenter(String localDataCenter) {
this.localDataCenter = localDataCenter;
}
@Override
public String getLocalDataCenter() {
return localDataCenter;
}
public void setPort(Integer port) {
this.port = port;
}
@Bean(name = "dbSession")
@Primary
public CqlSession session() {
String containerIpAddress = getContactPoints();
int containerPort = getPort();
InetSocketAddress containerEndPoint = new InetSocketAddress(containerIpAddress, containerPort);
CqlSessionBuilder builder = CqlSession.builder().withLocalDatacenter(getLocalDataCenter()).addContactPoint(containerEndPoint)
.withAuthCredentials(serverProps.getCassandraUserName(), serverProps.getCassandraPassword())
.withKeyspace(getKeyspaceName());
return builder.build();
}
@Bean("dbOperations")
public CassandraOperations cassandraOperationsB() {
return new CassandraTemplate(session(), cassandraConverter());
}
@Primary
@Bean(name = "dbTemplate")
@Override
public CassandraAdminTemplate cassandraTemplate() {
return new CassandraAdminTemplate(session(), cassandraConverter());
}
}
I am providing the username and password while building the CqlSession but still facing this exception. Is there anything I am doing incorrectly?