【问题标题】:Error messages on maven while compiling Storm topology编译 Storm 拓扑时 Maven 上的错误消息
【发布时间】:2016-02-06 16:50:30
【问题描述】:

当我尝试在 horton works 沙箱上编译我的代码时:

mvn compile exec:java -Dstorm.topology=ProvaTopology.java -e

而我的 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>Storm.practice</groupId>
  <artifactId>Storm.Prova</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>Storm.Prova</name>
  <url>http://maven.apache.org</url>

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

  <dependencies>
  <dependency>
    <groupId>org.apache.storm</groupId>
    <artifactId>storm-core</artifactId>
    <version>0.9.1-incubating</version>
    </dependency>
  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

所以当我尝试编译时,我遇到了一些错误,它显示如下:

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Storm.Prova 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Storm.Prova ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/prova/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ Storm.Prova ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ Storm.Prova ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.227s
[INFO] Finished at: Thu Nov 05 17:48:55 UTC 2015
[INFO] Final Memory: 11M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project Storm.Prova: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project Storm.Prova: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java are missing or invalid
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:220)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    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.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java are missing or invalid
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:581)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:534)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:97)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException

我正在使用带有 M2E 插件的 Eclipse Mars Web,以及用于 hortonworks 沙箱的推荐版本的 maven。

如果有人知道为什么会显示此错误,请告诉我。

提前致谢!

【问题讨论】:

    标签: java maven maven-plugin apache-storm


    【解决方案1】:

    从错误消息看来,您的 maven 插件找不到您的主类。如果你给出你的主类的完整包名怎么办?类似的东西

    -Dstorm.topology=com.xyz.wbx.ProvaTopology
    

    在尝试编译您的项目时替换为您的实际包名称。

    编辑

    您的错误消息说 exec-maven-plugin 找不到主类。您的 pom 似乎没有将其列为插件。基于this answer,在您的 pom.xml 中包含以下内容。 将它包含在依赖项标记之后。

    <build>
      <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>java</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>com.xyz.wbx.ProvaTopology</mainClass>
            </configuration>
            </plugin>
      </plugins>
    </build>
    

    对于完整的包名,不要包括 src.main.java,只需以域开头。通常是 com,org 等。

    【讨论】:

    • 谢谢,我已经尝试使用来自父项目目录(src.main,java..)的完整包和完整路径,但不起作用,同样的消息。 (抱歉其他文字,control+c错误)
    • 你是如何获得 exec-maven-plugin 的?你的 pom.xml 并没有说你有它。
    • 我真的不明白你的意思,这个 pom 是来自网络的样本,并为使用我的项目而编辑,也许它缺少那部分。对不起,我是一个使用 maven 的完整菜鸟。我从 -X(debug) 选项中得到了这个,可能有用:[DEBUG] (f) arguments = [] [DEBUG] (f) classpathScope = runtime
    • 检查我更新的答案。如果我的建议不起作用,您能否也更新您的 pom.xml,以便我查看您的 pom.xml 处于什么状态?
    • 我在搞定,我马上告诉你结果,谢谢
    猜你喜欢
    • 2016-04-16
    • 1970-01-01
    • 1970-01-01
    • 2015-08-06
    • 2019-08-04
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    • 2016-11-18
    相关资源
    最近更新 更多