Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: com/google/common/util/concurrent/FutureFallback

I'm seeing the following error :

java.lang.NoClassDefFoundError: com/google/common/util/concurrent/FutureFallback

when the cluster.connect() is called :

            String hosts = CassandraClientUtil.getHost();
            String localDC = CassandraClientUtil.getLocalDC();
            Cluster cluster = null;
            if (StringUtils.isNotEmpty(localDC))
            {
                cluster = Cluster.builder().addContactPoints(hosts.split(","))
                        .withCredentials(CassandraCopsComponentLogger.USER_NAME, CassandraCopsComponentLogger.AUTH_CODE)
                        .withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_ONE))
                        .withLoadBalancingPolicy(new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(localDC).build())).build();
            }
            else
            {
                cluster = Cluster.builder().addContactPoints(hosts.split(","))
                        .withCredentials(CassandraCopsComponentLogger.USER_NAME, CassandraCopsComponentLogger.AUTH_CODE)
                        .withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_ONE)).build();
            }

            Session session = cluster.connect();
            CassandraCopsComponentLogger.mappingManager = new MappingManager(session);

The pom.xml has the following dependencies :

<dependencies>
        <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>16.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-core</artifactId>
            <version>2.1.9</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty</artifactId>
            <version>3.9.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.codahale.metrics</groupId>
            <artifactId>metrics-core</artifactId>
            <version>3.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>   
        <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-mapping</artifactId>
            <version>2.1.9</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.3.1</version>
        </dependency>
  </dependencies>

I saw a post on stackoverflow here where they recommended to upgrade the guava version to 16.0.1 but that did not help me solve my problem. Some directions from here will be really helpful as I'm new to cassandra. To add more background this thing works as a standalone project, when I include this project as a maven dependency to some other project it raises this runtime error.

like image 654
Prasad Shinde Avatar asked Apr 25 '16 23:04

Prasad Shinde


1 Answers

com.google.common.util.concurrent.FutureFallback is deprecated in Guava 19.0 and removed since Guava 20.0.

Use Guava 19.0 and do not use Guava 20.0 or greater, until you upgrade the Cassandra driver.

like image 163
Hendy Irawan Avatar answered Oct 11 '22 22:10

Hendy Irawan