java.lang.NoClassDefFoundError [英] java.lang.NoClassDefFoundError

查看:45
本文介绍了java.lang.NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我编译项目时得到的

Here what i got when compile the project

通过这个命令

mvn compile exec:java -Dexec.classPathScope=compile -Dexec.mainClass=trident.myproject

得到这个

java.lang.NoClassDefFoundError: storm/trident/state/StateFactory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getMethod0(Class.java:2670)
at java.lang.Class.getMethod(Class.java:1603)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:662)
 Caused by: java.lang.ClassNotFoundException: storm.trident.state.StateFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 6 more

INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]   ------------------------------------------------------------------------
[INFO] An exception occured while executing the Java class. storm/trident  /state/StateFactory

storm.trident.state.StateFactory

我查看了文件夹,但找不到这个类!虽然我之前成功运行过

i reviewed the folder and can't find this class ! although i ran it before successfully

我把pom文件写成部分

i wrote pom file as parts

<dependencies>
        <dependency>
            <groupId>storm</groupId>
            <artifactId>storm</artifactId>
            <version>0.8.2</version>
            <scope>provided</scope>
        </dependency>

pom.xml 的第 2 部分

part 2 of pom.xml

<dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>colt</groupId>
        <artifactId>colt</artifactId>
        <version>1.2.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.0.0</version>
    </dependency>

pom.xml 的第 3 部分

part 3 of pom.xml

<dependency>
        <groupId>org.twitter4j</groupId>
        <artifactId>twitter4j-core</artifactId>
        <version>4.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.twitter4j</groupId>
        <artifactId>twitter4j-stream</artifactId>
        <version>4.0.2</version>
    </dependency>
            <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.17</version>
            </dependency>
</dependencies>

推荐答案

您可能已经更改了 pom.xml 文件中依赖项的范围.如果您的容器提供了对所提供的依赖项更改范围.
提供

You might have changed the scope of the dependency in your pom.xml file. If your container is providing the dependency change scope to provided.
<scope>provided</scope>

如果容器未提供要编译的依赖项更改范围.
编译

If container is not providing the dependency change scope to compile.
<scope>compile</scope>

这篇关于java.lang.NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆