随笔 - 597  文章 - 4  评论 - 445  阅读 - 424万

Caused by: java.lang.ClassNotFoundException: backtype.storm.topology.IRichSpout

1:初次运行Strom程序出现如下所示的错误,贴一下,方便脑补,也希望帮助到看到的小伙伴:

错误如下所示,主要问题是刚开始使用maven获取jar包的时候需要写<scope>provided</scope>,运行的时候需要把这行注释了即可,这是作用域的问题,开始需要在本地下载jar包,但是在虚拟机运行的时候已经存在这些jar包了,所以再写这句话就冲突了:

复制代码
 1 java.lang.NoClassDefFoundError: backtype/storm/topology/IRichSpout
 2     at java.lang.Class.getDeclaredMethods0(Native Method)
 3     at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
 4     at java.lang.Class.getMethod0(Class.java:2866)
 5     at java.lang.Class.getMethod(Class.java:1676)
 6     at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
 7     at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
 8 Caused by: java.lang.ClassNotFoundException: backtype.storm.topology.IRichSpout
 9     at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
10     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
11     at java.security.AccessController.doPrivileged(Native Method)
12     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
13     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
14     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
15     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
16     ... 6 more
17 Exception in thread "main" 
18 Process finished with exit code 1
复制代码

解决方法如下所示:

 贴下pom.xml文件:

复制代码
<?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>com.bie</groupId>
    <artifactId>storm</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- storm的依赖关系 -->
    <dependencies>
        <dependency>
            <groupId>org.apache.storm</groupId>
            <artifactId>storm-core</artifactId>
            <version>0.9.5</version>
            <!--<scope>provided</scope>-->
        </dependency>
    </dependencies>

    <!--如果依赖外部包,就打不进去外部包,所以需要引入下面所示-->
    <build>
        <plugins>
            <plugin>
                <!--把其他外部依赖的jar包打成一个大jar包-->
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>com.bie.wordcount.WordCountTopologyMain</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>
复制代码

停更......

posted on   别先生  阅读(4972)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示