storm-core-1.2.1.jar缺少类

时间:2018-03-19 12:24:43

标签: docker jar apache-storm classnotfoundexception nosuchmethoderror

我按照Docker中心列出的针对Storm 1.2.1的程序设置了最小的Storm群集。图像使用Storm分布。

我构建了另一个普通的maven项目,pom文件显示为last。我尝试运行storm-starter项目中的示例。在这里,我将LambdaTopology复制到了我的项目中。当我提交拓扑时,将LambdaTopology指定为主类。发生错误:

Running: /usr/lib/jvm/java-1.8-openjdk/jre/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/apache-storm-1.2.1 -Dstorm.log.dir=/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /apache-storm-1.2.1/*:/apache-storm-1.2.1/lib/*:/apache-storm-1.2.1/extlib/*:/storm-examples-1.0-SNAPSHOT-jar-with-dependencies.jar:/conf:/apache-storm-1.2.1/bin -Dstorm.jar=/storm-examples-1.0-SNAPSHOT-jar-with-dependencies.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} uni.mlgb.storm.examples.LambdaTopology lambda
Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/apache/storm/lambda/SerializableSupplier
        at uni.mlgb.storm.examples.LambdaTopology.run(LambdaTopology.java:48)
        at uni.mlgb.storm.examples.ConfigurableTopology.start(ConfigurableTopology.java:68)
        at uni.mlgb.storm.examples.LambdaTopology.main(LambdaTopology.java:29)
Caused by: java.lang.NoClassDefFoundError: org/apache/storm/lambda/SerializableSupplier
        ... 3 more
Caused by: java.lang.ClassNotFoundException: org.apache.storm.lambda.SerializableSupplier
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 3 more

我发现泊坞窗图片中的storm-core-1.2.1.jar遗漏了lambda目录下的所有类,例如SerializableSupplier。所以我将范围storm-core依赖项更改为compile。再次编译之后,我验证了现在jar文件中存在的SerializableSupplier。但是当采用sumpointted拓扑时,我又遇到了另一个错误:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/apache-storm-1.2.1/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/lambda.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Running: /usr/lib/jvm/java-1.8-openjdk/jre/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/apache-storm-1.2.1 -Dstorm.log.dir=/logs -Djav
a.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /apache-storm-1.2.1/*:/apache-storm-1.2.1/lib/*:/apache-storm-1.2.1/extlib/
*:/lambda.jar:/conf:/apache-storm-1.2.1/bin -Dstorm.jar=/lambda.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} uni.mlgb.storm.examples.Lam
bdaTopology lambda
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.storm.topology.TopologyBuilder.setSpout(Ljava/lang/String;Lorg/apache/storm/lambda/Se
rializableSupplier;)Lorg/apache/storm/topology/SpoutDeclarer;
at uni.mlgb.storm.examples.LambdaTopology.run(LambdaTopology.java:48)
at uni.mlgb.storm.examples.ConfigurableTopology.start(ConfigurableTopology.java:68
at uni.mlgb.storm.examples.LambdaTopology.main(LambdaTopology.java:29)

这个bug让我很困惑。我该如何解决?

我的pom文件依赖关系如下所示,从1.2.1版本开始构建,即2.0.0-SNAPSHOT。

<?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>uni.mlgb</groupId>
    <artifactId>storm-examples</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <dependencies>

        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <!--<version>1.2.1</version>-->
            <version>2.0.0-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass></mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

1 个答案:

答案 0 :(得分:0)

你正在混合两种不同的Storm版本。用于声明spout / bolt的Lambdas仅受Storm 2.0.0支持,因为早期版本必须与Java 7兼容。如果你想使用lambda支持,你必须使用Storm 2.0.0(目前尚未发布,但你可以从https://github.com/apache/storm检查并构建它而不是1.2.1。

您需要添加到Maven for Storm 2.0.0的依赖项已更改,请使用storm-client而不是storm-core

如果需要在Storm 1.2.1群集上运行拓扑,则应仅依赖storm-core 1.2.1,而不是尝试使用2.0.0功能。