Why can't I run the example from storm-starter using this command?

强颜欢笑 提交于 2020-01-15 15:28:54

问题


I've have had no experience using Storm or Maven before, and I'm working on my starter project. When I compile the starter project uploaded on the git website using the command given there i.e. this:

mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=storm.starter.ExclamationTopology

I can run the Exclamation topology class, but when I use this command:

java -cp ./target/storm-starter-0.0.1-SNAPSHOT-jar-with-dependencies.jar storm.starter.ExclamationTopology

I can't run it.

By the way, I got the second command from the maven tutorial on apache's site Could someone point out what am I doing wrong here?

PS: This is the error http://pastebin.com/A1PQbB3r


回答1:


Your pom probably has the scope for the storm dependency as "provided" which means that it will be in the runtime classpath, but not in the jar-with-dependencies. Try changing the scope to "compile"




回答2:


You are hitting the java.lang.NoClassDefFoundError since the storm jars are not in your classpath. For your second command, put the storm jar and the storm/lib in your classpath and it should work as expected.




回答3:


The scope for the Storm dependency should be different depending on whether your are running in local mode or cluster.

For local mode you need to set the scope to "compile" or leave the tag empty as scope defaults to "compile".

In order to submit your topology to a cluster you need to set the scope to "provided", otherwise the Storm jar will be packaged inside your topology jar and when deploying to the cluster there will be 2 Storm jars in the classpath: the one inside your topology and the one inside the Storm installation directory.



来源:https://stackoverflow.com/questions/16903185/why-cant-i-run-the-example-from-storm-starter-using-this-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!