从同一程序调用cassandra和弹性搜索时出现异常

时间:2017-03-31 16:10:04

标签: java cassandra-2.0 datastax-java-driver elasticsearch-5

我正在尝试将我在cassandra的数据索引到托管在云中的弹性搜索。我能够使用传输客户端轻松地使用弹性搜索连接和索引虚拟数据。但是,当我在我的pom文件中添加数据存储驱动程序依赖关系以连接到cassandra时,我得到了以下的exeptions。奇怪的是我甚至没有连接到cassandra集群。 提前致谢

线程“main”中的异常java.lang.AbstractMethodError:io.netty.util.concurrent.MultithreadEventExecutorGroup.newChild(Ljava / util / concurrent / Executor; [Ljava / lang / Object;)Lio / netty / util / concurrent / EventExecutor;     at io.netty.util.concurrent.MultithreadEventExecutorGroup。(MultithreadEventExecutorGroup.java:84)     在io.netty.util.concurrent.MultithreadEventExecutorGroup。(MultithreadEventExecutorGroup.java:58)     在io.netty.util.concurrent.MultithreadEventExecutorGroup。(MultithreadEventExecutorGroup.java:47)     at io.netty.channel.MultithreadEventLoopGroup。(MultithreadEventLoopGroup.java:49)     在io.netty.channel.nio.NioEventLoopGroup。(NioEventLoopGroup.java:68)     在io.netty.channel.nio.NioEventLoopGroup。(NioEventLoopGroup.java:63)     在io.netty.channel.nio.NioEventLoopGroup。(NioEventLoopGroup.java:54)     在org.elasticsearch.transport.netty4.Netty4Transport.createBootstrap(Netty4Transport.java:201)     在org.elasticsearch.transport.netty4.Netty4Transport.doStart(Netty4Transport.java:172)     at org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4Transport.doStart(SecurityNetty4Transport.java:74)     在org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:69)     在org.elasticsearch.transport.TransportService.doStart(TransportService.java:196)     在org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:69)     在org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:208)     在org.elasticsearch.client.transport.TransportClient。(TransportClient.java:268)     在org.elasticsearch.transport.client.PreBuiltTransportClient。(PreBuiltTransportClient.java:125)     在org.elasticsearch.xpack.client.PreBuiltXPackTransportClient。(PreBuiltXPackTransportClient.java:55)     在org.elasticsearch.xpack.client.PreBuiltXPackTransportClient。(PreBuiltXPackTransportClient.java:50)     在org.elasticsearch.xpack.client.PreBuiltXPackTransportClient。(PreBuiltXPackTransportClient.java:46)

1 个答案:

答案 0 :(得分:1)

为了解决DataStax java驱动程序的Netty依赖关系与其他库对maven的依赖关系之间的潜在冲突,您可以使用驱动程序jar的“着色”分类器,如'Using the shaded jar' page上的驱动程序文档中所述:< / p>

<dependency>
    <groupId>com.datastax.cassandra</groupId>
    <artifactId>cassandra-driver-core</artifactId>
    <version>3.2.0</version>
    <classifier>shaded</classifier>
    <!-- Because the shaded JAR uses the original POM, you still need
        to exclude this dependency explicitly: -->
    <exclusions>
        <exclusion>
        <groupId>io.netty</groupId>
        <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>

注意,如果您不使用maven,其他构建工具(如gradle)应该有一种指定分类器的方法,否则您可以直接从maven下载带阴影的jar。