0

I followed the procedure listed on the Docker hub for Storm 1.2.1 to set up a minimum Storm cluster. And the image uses a Storm distribution as is.

I build another plain maven project and pom file is shown as last. I try to run the examples from storm-starter project. Here I copied LambdaTopology into my project. when I submit the topology assigning LambdaTopology as the main class. Error occurs:

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

I found that the storm-core-1.2.1.jar in the docker image missing all classes under lambda directory, e.g., SerializableSupplier. So I changed the scope storm-core dependency to compile. After compiled again, I validated that SerializableSupplier exsisted in the jar file now. But when sumbitted topology, I got another error:

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)

This bug really confused me. How can I solve it?

My pom file dependency as below built from version 1.2.1 which is 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>
LeoZhang
  • 185
  • 1
  • 10

1 Answers1

0

You are mixing up two different Storm versions. Lambdas for declaring spouts/bolts are only supported by Storm 2.0.0 because earlier versions have to be Java 7 compatible. If you want to use the lambda support, you have to use Storm 2.0.0 (not released at this time, but you can check out and build it from https://github.com/apache/storm) and not 1.2.1.

The dependency you need to add to Maven for Storm 2.0.0 has changed, use storm-client instead of storm-core.

If you need to run your topology on a Storm 1.2.1 cluster, you should only depend on storm-core 1.2.1, and not try to use the 2.0.0 features.

Stig Rohde Døssing
  • 3,621
  • 2
  • 7
  • 7