“线程中的异常”;“主要”;java.lang.RuntimeException:在执行Storm时发现多个defaults.yaml资源

“线程中的异常”;“主要”;java.lang.RuntimeException:在执行Storm时发现多个defaults.yaml资源,java,apache-storm,Java,Apache Storm,我正在尝试执行这里的教程 卡夫卡风暴拓扑代码为: package com.storm; import storm.kafka.KafkaSpout; import storm.kafka.SpoutConfig; import storm.kafka.StringScheme; import storm.kafka.ZkHosts; import backtype.storm.Config; import backtype.storm.LocalCluster; import backtype

我正在尝试执行这里的教程

卡夫卡风暴拓扑代码为:

package com.storm;

import storm.kafka.KafkaSpout;
import storm.kafka.SpoutConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.topology.TopologyBuilder;

public class KafkaStormTopology {
public static void main(String[] args) {
  ZkHosts zk = new ZkHosts("10.25.3.208:2181");
  SpoutConfig config = new SpoutConfig(zk,"deepthy","",
"KafkaStorm");

 config.scheme = new SchemeAsMultiScheme(new StringScheme());

  config.forceFromStart = true;

  TopologyBuilder builder = new TopologyBuilder();
  builder.setSpout("KafkaSpout", new KafkaSpout(config), 1);
  builder.setBolt("Bolt", new FileBolt(), 1).globalGrouping("KafkaSpout");

  LocalCluster cluster = new LocalCluster();

  Config conf = new Config();
  conf.setDebug(true);
  cluster.submitTopology("SampleTopology", conf, builder.createTopology());
 }
}
My 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>com.deepthy.storm</groupId>
<artifactId>Storm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Storm</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
    <repository>
        <id>clojars.org</id>
        <url>http://clojars.org/repo</url>
    </repository>
    <repository>
        <id>central</id>
        <url>http://repo1.maven.org/maven2/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
      <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-core</artifactId>
        <version>0.9.2-incubating</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.storm</groupId>
        <artifactId>storm-kafka</artifactId>
        <version>0.9.2-incubating</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.2.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.storm.KafkaStormTopology</mainClass>
</manifest>
 </archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
 </goals>
 </execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我尝试在pom.xml中将范围从“compile”更改为“provided”,但得到了相同的错误


关于如何解决此问题的任何建议。

您的jar包含文件
defaults.yaml
,其中不允许使用该文件。您需要从jar组装步骤中排除该文件。我建议使用
maven-jar-plugin
而不是
maven-assembly-plugin
,并“手动”包含所有需要的文件——这也有助于“最小化”您的jar,使其只包含您需要的内容:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>

        <executions>
                <execution>
                    <id>YOUR-ID</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <finalName>JAR-FILE-NAME-PREFIX</finalName>
                        <classifier>JAR-FILE-NAME-SUFFIX</classifier>

                        <archive>
                            <manifestEntries>
                                <mainClass>com.storm.KafkaStormTopology</mainClass>
                            </manifestEntries>
                        </archive>

                        <includes>
                            <include>packages/to/include/**/*.java</include>
                            <!-- more include here -->
                        <includes>
                    </configuration>
                </execution>
        </executions>
</plugin>

org.apache.maven.plugins
maven jar插件
你的身份证
包裹
罐子
JAR-FILE-NAME-PREFIX
JAR-FILE-NAME-SUFFIX
com.storm.kafkastrmtopology
包/to/include/***.java

在pom文件中排除default.yaml文件

在你的阴影中添加插件 : META-INF/.SF META-INF/.DSA META-INF/.RSA 亚姆先生

您正在运行什么命令来上传jar?
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>

        <executions>
                <execution>
                    <id>YOUR-ID</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <finalName>JAR-FILE-NAME-PREFIX</finalName>
                        <classifier>JAR-FILE-NAME-SUFFIX</classifier>

                        <archive>
                            <manifestEntries>
                                <mainClass>com.storm.KafkaStormTopology</mainClass>
                            </manifestEntries>
                        </archive>

                        <includes>
                            <include>packages/to/include/**/*.java</include>
                            <!-- more include here -->
                        <includes>
                    </configuration>
                </execution>
        </executions>
</plugin>