找到了多个defaults.yaml资源。您可能正在将Storm jar与拓扑jar

时间:2016-06-22 14:01:40

标签: java maven apache-storm

所以我现在更新了问题和标题,因为现在我知道了这个问题。 这是工作日志,我知道有很多像这样的问题(here),但我不能让任何解决方案无论我做什么。

  

编辑:它与链接中提到的问题相同,但有   在下面的答案中提到的不同的原因。

这是工作人员日志。

2016-06-23 00:10:56.115 STDERR [INFO] Exception in thread "main" java.lang.ExceptionInInitializerError
2016-06-23 00:10:56.122 STDERR [INFO]   at org.apache.storm.config$read_storm_config.invoke(config.clj:78)
2016-06-23 00:10:56.124 STDERR [INFO]   at org.apache.storm.daemon.worker$_main.invoke(worker.clj:768)
2016-06-23 00:10:56.124 STDERR [INFO]   at clojure.lang.AFn.applyToHelper(AFn.java:165)
2016-06-23 00:10:56.124 STDERR [INFO]   at clojure.lang.AFn.applyTo(AFn.java:144)
2016-06-23 00:10:56.125 STDERR [INFO]   at org.apache.storm.daemon.worker.main(Unknown Source)
2016-06-23 00:10:56.125 STDERR [INFO] Caused by: java.lang.RuntimeException: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/media/bishoymak/All/College/New%20GP/Second/Programs/storm/lib/storm-core-1.0.1.jar!/defaults.yaml, jar:file:/media/bishoymak/All/College/New%20GP/Second/Programs/storm/storm-local/supervisor/stormdist/LogAnalyserStorm-1-1466632686/stormjar.jar!/defaults.yaml]
2016-06-23 00:10:56.126 STDERR [INFO]   at org.apache.storm.utils.Utils.findAndReadConfigFile(Utils.java:307)
2016-06-23 00:10:56.126 STDERR [INFO]   at org.apache.storm.utils.Utils.readDefaultConfig(Utils.java:351)
2016-06-23 00:10:56.127 STDERR [INFO]   at org.apache.storm.utils.Utils.readStormConfig(Utils.java:387)
2016-06-23 00:10:56.127 STDERR [INFO]   at org.apache.storm.utils.Utils.<clinit>(Utils.java:119)
2016-06-23 00:10:56.127 STDERR [INFO]   ... 5 more
2016-06-23 00:10:56.128 STDERR [INFO] Caused by: java.io.IOException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar. [jar:file:/media/bishoymak/All/College/New%20GP/Second/Programs/storm/lib/storm-core-1.0.1.jar!/defaults.yaml, jar:file:/media/bishoymak/All/College/New%20GP/Second/Programs/storm/storm-local/supervisor/stormdist/LogAnalyserStorm-1-1466632686/stormjar.jar!/defaults.yaml]

这是我的pom.xml

<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>StormExample</groupId>
  <artifactId>StormExample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source/>
          <target/>
        </configuration>
      </plugin>
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.6</version>

          <executions>
            <execution>
              <id>LogAnalyserStorm</id>
              <phase>package</phase>
              <goals>
                <goal>jar</goal>
              </goals>
              <configuration>
                <includes>
                  <include>LogAnalyserStorm.class</include>
              <include>FakeCallLogReaderSpout.class</include>
              <include>CallLogCounterBolt.class</include>
              <include>CallLogCreatorBolt.class</include>
                </includes>
              </configuration>
            </execution>
          </executions>
        </plugin>

    </plugins>
  </build>
    <repositories> 
      <repository> 
        <id>clojars.org</id> 
        <url>http://clojars.org/repo</url> 
      </repository> 
    </repositories> 
    <dependencies>
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>1.0.1</version>
          <scope>provided</scope>
        </dependency>
      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.1.1.Final</version>
        <scope>provided</scope>
      </dependency>
    </dependencies>

我使用了mvn jar:jar和mvn包,但它总是包含风暴核心,虽然我说它只包括4个类,所以请告诉我我做错了什么。     

这是我的拓扑代码:

public static void main(String[] args) throws Exception{
          //Create Config instance for cluster configuration
          Config config = new Config();
          config.setDebug(true);

          TopologyBuilder builder = new TopologyBuilder();
          builder.setSpout("call-log-reader-spout", new FakeCallLogReaderSpout());

          builder.setBolt("call-log-creator-bolt", new CallLogCreatorBolt())
             .shuffleGrouping("call-log-reader-spout");

          builder.setBolt("call-log-counter-bolt", new CallLogCounterBolt())
             .fieldsGrouping("call-log-creator-bolt", new Fields("call"));

          System.setProperty("storm.jar", "/media/bishoymak/All/College/New GP/Second/Programs/storm/lib/storm-core-1.0.1.jar");
          StormSubmitter.submitTopology("LogAnalyserStorm", config, builder.createTopology());

1 个答案:

答案 0 :(得分:2)

这个问题不得不对pom.xml做什么,只需删除这一行

System.setProperty("storm.jar", "/media/bishoymak/All/College/New GP/Second/Programs/storm/lib/storm-core-1.0.1.jar");