找不到org.apache.thrift7.TBase类

时间:2013-07-22 13:40:30

标签: java maven maven-2 thrift thrift-protocol

使用以下maven命令执行拓扑时出错:

mvn exec:java -Dexec.mainClass="com.test.newpackage.TopologyMain" -Dexec.args="resource/words.txt"

如果我尝试使用以下命令:

java -cp ./target/wordcount-0.0.1.jar:/usr/local/hadoop/storm/storm-0.8.1.jar:/usr/local/hadoop/storm/lib/*:/usr/local/hadoop/storm/conf/storm.yaml com.test.newpackage.TopologyMain resource/words.txt

既不会出错也不会输出。即使我使用以下方法将拓扑提交到风暴:

storm jar StormEclipse.jar com.test.newpackage.TopologyMain /resource/words.txt

此拓扑未在ui(localhost:8080)上列出。

 [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'exec'.
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Unnamed - com.test.newpackage:wordcount:jar:0.0.1
    [INFO]    task-segment: [exec:java]
    [INFO] ------------------------------------------------------------------------
    [INFO] Preparing exec:java
    [INFO] No goals needed for project - skipping
    [INFO] [exec:java {execution: default-cli}]
    [WARNING] 
    java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
        at java.lang.Thread.run(Thread.java:724)
    Caused by: java.lang.NoClassDefFoundError: org/apache/thrift7/TBase
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:788)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:447)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at backtype.storm.topology.TopologyBuilder.initCommon(TopologyBuilder.java:215)
        at backtype.storm.topology.TopologyBuilder.setSpout(TopologyBuilder.java:178)
        at backtype.storm.topology.TopologyBuilder.setSpout(TopologyBuilder.java:164)
        at com.test.newpackage.TopologyMain.main(TopologyMain.java:12)
        ... 6 more
    Caused by: java.lang.ClassNotFoundException: org.apache.thrift7.TBase
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 21 more
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] An exception occured while executing the Java class. null

    org.apache.thrift7.TBase
    [INFO] ------------------------------------------------------------------------
    [INFO] For more information, run Maven with the -e switch
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1 second
    [INFO] Finished at: Mon Jul 22 18:55:23 IST 2013
    [INFO] Final Memory: 5M/15M
    [INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:0)

请检查风暴依赖的范围。 storm wiki中建议的示例pom.xml设置了测试范围。因此,当您使用maven执行时,它将无法解决风暴依赖性。

如果要通过maven运行它,请删除测试范围