如何在风暴中解决java.lang.NoClassDefFoundError:org / apache / curator / RetryPolicy

时间:2015-03-27 10:15:51

标签: apache-storm apache-kafka

我该如何解决

  

java.lang.NoClassDefFoundError:com / google / common / base / Preconditions   在   org.apache.curator.ensemble.fixed.FixedEnsembleProvider。(FixedEnsembleProvider.java:39)   在org.apache.curator.framework。

  

java.lang.NoClassDefFoundError:org / apache / curator / RetryPolicy

在storm-kafka整合中。

我正在使用:

  • kafka_2.9.2-0.8.1.1

  • Zookeeper - 3.4.6

  • 风暴 - 0.9.3

更新

的pom.xml

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-reflect</artifactId>
        <version>2.10.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-kafka</artifactId>
        <version>0.9.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.9.2</artifactId>
        <version>0.8.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.zookeeper</groupId>
        <artifactId>zookeeper</artifactId>
        <version>3.4.6</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-core</artifactId>
        <version>0.9.3</version>
    </dependency>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
        <version>2.6.0</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

2 个答案:

答案 0 :(得分:1)

在pom.xml中添加以下行

<dependency>
  <groupId>org.apache.curator</groupId>
  <artifactId>curator-test</artifactId>
  <version>2.4.0</version>
  <exclusions>
    <exclusion>
      <groupId>org.jboss.netty</groupId>
      <artifactId>netty</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
    </exclusion>
  </exclusions>
</dependency>

答案 1 :(得分:1)

对于org/apache/curator/RetryPolicy,您应该使用

<dependency>
  <groupId>org.apache.curator</groupId>
  <artifactId>curator-client</artifactId>
  <version>2.11.0</version>
</dependency>

对于ZooKeeper 3.4.6的注意事项,与Curator兼容的最新版本(截至本文)与2.11.0相符。

curator-client也需要curator-framework。所以你可能想要添加

<dependency>
  <groupId>org.apache.curator</groupId>
  <artifactId>curator-framework</artifactId>
  <version>2.11.0</version>
</dependency>