簡體   English   中英

從同一程序調用 cassandra 和彈性搜索時出現異常

[英]Exception while calling cassandra and elastic search from same program

我正在嘗試將 cassandra 的數據索引到托管在雲中的彈性搜索。 我能夠使用傳輸客戶端輕松地通過彈性搜索連接和索引虛擬數據。 但是,當我在我的 pom 文件中添加 datastax 驅動程序依賴項以連接到 cassandra 時,我得到以下異常。 奇怪的是我什至沒有連接到 cassandra 集群。 提前致謝

線程“主”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) at io.netty.util.concurrent.MultithreadEventExecutorGroup.(MultithreadEventExecutorGroup.java:58) at io.netty.util.concurrent.MultithreadEventExecutorGroup.(MultithreadEventExecutorGroup. java:47) at io.netty.channel.MultithreadEventLoopGroup.(MultithreadEventLoopGroup.java:49) at io.netty.channel.nio.NioEventLoopGroup.(NioEventLoopGroup.java:68) at io.netty.channel.nio.NioEventLoopGroup.( NioEventLoopGroup.java:63) at io.netty.channel.nio.NioEventLoopGroup.(NioEventLoopGroup.java:54) at org.elasticsearch.transport.netty4.Netty4Transport.createBootstrap(Netty4Transport.java:201) at org.elasticsearch.transport.網狀 4.Netty4Transport.doStart(Netty4Transport.java:172) at org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4Transport.doStart(SecurityNetty4Transport.java:74) at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent. java:69) at org.elasticsearch.transport.TransportService.doStart(TransportService.java:196) at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:69) at org.elasticsearch.client.transport.TransportClient .buildTemplate(TransportClient.java:208) at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:268) at org.Z18897DCFCE6A4E 7AE63A3BAEED443C48Z.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:125) at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:55) at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:50 ) 在 org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:46)

To get around potential conflicts between DataStax java driver's dependency of Netty and other libraries' dependencies on maven, you could use the 'shaded' classifier of the driver jar as described in the driver docs on the 'Using the shaded jar' page :

<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>

Note if you aren't using maven, other build tools like gradle should have a way of specifying the classifier, otherwise you can download the shaded jar directly from maven.

我使用這個 pom.xml 這對我有用

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>mavenproject2</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
         <cassandra-driver-core.version>3.1.2</cassandra-driver-core.version>
        <cassandra-unit.version>3.1.1.0</cassandra-unit.version>
        <datastax-cassandra.version>4.1.0</datastax-cassandra.version>
    </properties>
    <dependencies>
       
            <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-core</artifactId>
            <version>${cassandra-driver-core.version}</version>
            <optional>true</optional>
            <exclusions>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
                 <exclusion>
        <groupId>io.netty</groupId>
        <artifactId>*</artifactId>
        </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.cassandraunit/cassandra-unit -->
        <dependency>
            <groupId>org.cassandraunit</groupId>
            <artifactId>cassandra-unit</artifactId>
            <version>${cassandra-unit.version}</version>
                <exclusions>
        <exclusion>
        <groupId>io.netty</groupId>
        <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
        </dependency>
        <!-- DataStax Cassandra -->
        <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>
        <dependency>
            <groupId>com.datastax.oss</groupId>
            <artifactId>java-driver-query-builder</artifactId>
            <version>${datastax-cassandra.version}</version>
        </dependency>
         <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <version>1.7.5</version>
   </dependency>
   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <version>1.6.4</version>
   </dependency>
 <dependency>
  <groupId>com.datastax.oss</groupId>
  <artifactId>java-driver-core-shaded</artifactId>
  <version>4.5.1</version>
</dependency>

    </dependencies>
    
</project>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM