문제

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?

도움이 되었습니까?

해결책 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>

다른 팁

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top