title: Cassandra + SpringBoot, java.lang.ClassNotFoundException: com.datastax.oss.protocol.internal.SegmentCodec
body: <p>I'm trying to create a Spring application using Cassandra DB. But getting following error when I try to run the application.</p>
  <pre><code>Caused by: java.lang.NoClassDefFoundError: com/datastax/oss/protocol/internal/SegmentCodec
      ... 103 common frames omitted
  Caused by: java.lang.ClassNotFoundException: com.datastax.oss.protocol.internal.SegmentCodec
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_152-release]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_152-release]
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_152-release]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_152-release]
      ... 103 common frames omitted
  </code></pre>
  <p>Spring Boot version: 2.3.4.RELEASE</p>
  <p>Cassandra(spring-boot-starter-data-cassandra) version: 3.0.4</p>
  <p>application.yml file:</p>
  <pre><code>spring:
  
    data:
      cassandra:
        keyspaceName: my_keyspace
        contactPoints: localhost
        port: 9042
        schema-action: CREATE_IF_NOT_EXISTS
        local-datacenter: datacenter1
  </code></pre>
  <p>CassandraConfig.java</p>
  <pre><code>@Configuration
  @EnableCassandraRepositories(basePackages = &quot;com.myproject.repository&quot;)
  public class CassandraConfig extends AbstractCassandraConfiguration {
  
      @Value(&quot;${spring.data.cassandra.keyspaceName}&quot;)
      private String keyspace;
  
      @Value(&quot;${spring.data.cassandra.contactPoints}&quot;)
      private String contactPoints;
  
      @Value(&quot;${spring.data.cassandra.port}&quot;)
      private int port;
  
      @Value(&quot;${spring.data.cassandra.local-datacenter}&quot;)
      private String dataCenter;
  
      @Override
      public SchemaAction getSchemaAction() {
          return SchemaAction.CREATE_IF_NOT_EXISTS;
      }
  
      @Override
      protected SessionBuilderConfigurer getSessionBuilderConfigurer() {
          return new SessionBuilderConfigurer() {
              @Override
              public CqlSessionBuilder configure(CqlSessionBuilder cqlSessionBuilder) {
  
                  return cqlSessionBuilder
                          .addContactPoint(new InetSocketAddress(
                                  contactPoints,
                                  getPort()))
                          ;
  
              }
          };
      }
  
      @Override
      protected List&lt;CreateKeyspaceSpecification&gt; getKeyspaceCreations() {
          return Arrays.asList(CreateKeyspaceSpecification
                  .createKeyspace(getKeyspaceName())
                  .ifNotExists(true)
                  .withSimpleReplication()
                  .with(KeyspaceOption.DURABLE_WRITES));
  
      }
  
      @Override
      protected KeyspacePopulator keyspacePopulator() {
          ResourceKeyspacePopulator keyspacePopulate = new ResourceKeyspacePopulator();
          keyspacePopulate.setSeparator(&quot;;&quot;);
          keyspacePopulate.setScripts(new ClassPathResource(&quot;table-schema.cql&quot;));
          return keyspacePopulate;
      }
  
      @Override
      protected String getKeyspaceName() {
          return keyspace;
      }
  
      @Override
      protected int getPort(){
          return port;
      }
  
      @Override
      public String[] getEntityBasePackages() {
          return new String[]{&quot;com.myproject.entity&quot;};
      }
  
      @Override
      protected String getLocalDataCenter() {
          return dataCenter;
      }
  
  }
  </code></pre>
  <p>table-schema.cql</p>
  <pre><code>CREATE TABLE IF NOT EXISTS orders (order_id text, user_name text, created_at timestamp, item_id text, PRIMARY KEY ((order_id), item_id));
  </code></pre>
  <p>Following dependencies are present in pom.xml(driver.version is 4.9.0)</p>
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;com.datastax.oss&lt;/groupId&gt;
              &lt;artifactId&gt;java-driver-core&lt;/artifactId&gt;
              &lt;version&gt;${driver.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.datastax.oss&lt;/groupId&gt;
              &lt;artifactId&gt;java-driver-query-builder&lt;/artifactId&gt;
              &lt;version&gt;${driver.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.datastax.oss&lt;/groupId&gt;
              &lt;artifactId&gt;java-driver-mapper-runtime&lt;/artifactId&gt;
              &lt;version&gt;${driver.version}&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>