Frage

I am currently unable to connect to my cassandra database using the datastax driver. I am getting the following error:

com.datastax.driver.core.TransportException: [/127.0.0.1] Unexpected exception triggered (java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableSet;)
    at com.datastax.driver.core.Connection$Dispatcher.exceptionCaught(Connection.java:556)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:122)

Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableSet;
    at com.datastax.driver.core.DataType.<clinit>(DataType.java:144)
    at com.datastax.driver.core.Codec.<clinit>(Codec.java:31)

However, I have included the guava artefact in my pom.xml as follows:

<!-- Datastax driver -->

    <dependency>
        <groupId>com.datastax.cassandra</groupId>
        <artifactId>cassandra-driver-core</artifactId>
        <version>1.0.4</version>
    </dependency>

    <!-- Cassandra -->
    <dependency>
        <groupId>org.apache.cassandra</groupId>
        <artifactId>cassandra-all</artifactId>
        <version>1.2.9</version>
    </dependency>

    <!-- guava --<
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>15.0</version>
    </dependency>

Full pom.xml: http://pastebin.ubuntu.com/6358603/

Am I missing a dependency?

War es hilfreich?

Lösung 2

Based on the advice of this question: no such method error: ImmutableList.copyOf()

I had to exclude the google collections jar:

    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zkspring-core</artifactId>
        <version>3.1</version>
        <exclusions>
            <exclusion>
                <groupId>com.google.collections</groupId>
                <artifactId>google-collections</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Andere Tipps

According to its POM, version 1.0.4 of cassandra-driver-core uses version 14.0.1 of Guava, not version 15.0. I'm guessing you are seeing a version clash. Even if that version difference is not the cause of this problem, it might cause other problems.

You do not usually need to include transitive dependencies in POMs, Maven takes care of them for you. Or does your own code use Guava itself?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top