Search code examples
javaapache-storm

"Error: Could not find or load main class" error when using "storm jar"


I checked that Java Version, CLASSPATH, Java Build Path And Properties > Run/Debug Settings

But I can't resolve this error Could not find or load main class What information do I need to solve this problem?

This is error and my computer information

#storm jar tims-0.0.1-SNAPSHOT.jar com.clunix.tims.TIMSTopology TIMSTopology
Running: /usr/local/jdk1.8.0_151/bin/java -client -Ddaemon.name= -Dstorm.options= -Dstorm.home=/storm/storm -Dstorm.log.dir=/storm/storm/logs -Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib -Dstorm.conf.file= -cp /storm/storm/lib/storm-core-1.1.1.jar:/storm/storm/lib/kryo-3.0.3.jar:/storm/storm/lib/reflectasm-1.10.1.jar:/storm/storm/lib/asm-5.0.3.jar:/storm/storm/lib/minlog-1.3.0.jar:/storm/storm/lib/objenesis-2.1.jar:/storm/storm/lib/clojure-1.7.0.jar:/storm/storm/lib/ring-cors-0.1.5.jar:/storm/storm/lib/disruptor-3.3.2.jar:/storm/storm/lib/log4j-api-2.8.2.jar:/storm/storm/lib/log4j-core-2.8.2.jar:/storm/storm/lib/log4j-slf4j-impl-2.8.2.jar:/storm/storm/lib/slf4j-api-1.7.21.jar:/storm/storm/lib/log4j-over-slf4j-1.6.6.jar:/storm/storm/lib/servlet-api-2.5.jar:/storm/storm/lib/storm-rename-hack-1.1.1.jar:tims-0.0.1-SNAPSHOT.jar:/storm/storm/conf:/storm/storm/bin -Dstorm.jar=tims-0.0.1-SNAPSHOT.jar -Dstorm.dependency.jars= -Dstorm.dependency.artifacts={} com.clunix.tims.TIMSTopology TIMSTopology
Error: Could not find or load main class com.clunix.tims.TIMSTopology

# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

#echo $CLASSPATH
/usr/local/jdk1.8.0_151/lib/tools.jar:.

I think that I Should modify it... It's right? 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.clunix</groupId>
        <artifactId>tims</artifactId>
        <version>0.0.1-SNAPSHOT</version>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>

        <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>1.1.0</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.2.1</version>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <mainClass>com.clunix.tims.TIMSTopology</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>

Java Build Path

Run Configurations

Thanks in advance for your response.


Solution

  • I think you can add this plugin inside you pom.xml and retry it.

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>you spring boot version</version>
        <configuration>
          <mainClass>your main class</mainClass>
        </configuration>
    </plugin>