Maven webstart 插件找不到依赖项

发布于 2024-08-11 05:49:47 字数 6744 浏览 4 评论 0原文

希望有人能帮助我解决这个奇怪的问题。我正在尝试运行 webstart 插件,但它似乎无法在正在生成的 jar 中找到主类。 pom 非常简单,并且类 Test 存在,并且正在编译并放入 jar 中。有人可以指出我正确的方向吗?

<project>
  <modelVersion>4.0.0</modelVersion>
  <name>Desktop Components</name>
  <groupId>com.test</groupId>
  <artifactId>test</artifactId>
  <version>1.0</version>
  <packaging>jar</packaging>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo.webstart</groupId>
        <artifactId>webstart-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>jnlp-download-servlet</goal>
            </goals>
          </execution>
        </executions>

        <configuration>
          <jnlpFiles>
            <jnlpFile>
              <jarResources>
                <jarResource>
                  <groupId>com.test</groupId>
                  <artifactId>test</artifactId>
                  <version>1.0</version>
                  <mainClass>Test</mainClass>
                </jarResource>
              </jarResources>
            </jnlpFile>
          </jnlpFiles>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

以下是 Maven 跟踪:

C:\TEMP\webstart-test>mvn webstart:jnlp –e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Desktop Components
[INFO]    task-segment: [webstart:jnlp] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing webstart:jnlp
[INFO] ------------------------------------------------------------------------
[INFO] Building Desktop Components
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\TEMP\webstart-test\src\main\resources
[INFO] [webstart:jnlp-download-servlet {execution: default}]
[INFO] No templateFilename found for launch2.jnlp. Will use the default template.
[INFO] No resources found in C:\TEMP\webstart-test\src\main\jnlp\resources
Downloading: http://repo1.maven.org/maven2/com/test/test/1.0/test-1.0.pom
[INFO] Unable to find resource 'com.test:test:pom:1.0' in repository central (http://repo1.maven.org/maven2)
No template specified Using default one.

***** Webstart JAR URL: jar:file:/C:/apache-maven-2.2.1/repo/org/codehaus/mojo/webstart/webstart-maven-plugin/1.0-alpha-2/webstart-maven-plugin-1.0-alpha-2.jar!
/
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\TEMP\webstart-test\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: C:\TEMP\webstart-test\target\test-1.0.jar
[INFO] [webstart:jnlp {execution: default-cli}]
[INFO] No resources found in C:\TEMP\webstart-test\src\main\jnlp\resources
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failure to run the plugin:
[INFO] ------------------------------------------------------------------------
[INFO] Trace

跟踪

org.apache.maven.lifecycle.LifecycleExecutionException: Failure to run the plugin:
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:592)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

现在是由跟踪引起的

Caused by: org.apache.maven.plugin.MojoExecutionException: Failure to run the plugin:
        at org.codehaus.mojo.webstart.AbstractJnlpMojo.execute(AbstractJnlpMojo.java:289)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        ... 17 more

Caused by: java.lang.NullPointerException
        at org.codehaus.mojo.webstart.AbstractJnlpMojo.execute(AbstractJnlpMojo.java:214)
        ... 19 more

,最后是 Maven 跟踪

[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Fri Nov 13 11:16:54 GMT 2009
[INFO] Final Memory: 12M/22M
[INFO] ------------------------------------------------------------------------

Hoping someone can help me with this strange one. I’m trying to run the webstart plugin but it doesn’t seem to be able to find the main class within the jar being produce. The pom is as simple as it can get, and the class Test exists, and is being compiled and placed in the jar. Can someone please point me in the right direction?

<project>
  <modelVersion>4.0.0</modelVersion>
  <name>Desktop Components</name>
  <groupId>com.test</groupId>
  <artifactId>test</artifactId>
  <version>1.0</version>
  <packaging>jar</packaging>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo.webstart</groupId>
        <artifactId>webstart-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>jnlp-download-servlet</goal>
            </goals>
          </execution>
        </executions>

        <configuration>
          <jnlpFiles>
            <jnlpFile>
              <jarResources>
                <jarResource>
                  <groupId>com.test</groupId>
                  <artifactId>test</artifactId>
                  <version>1.0</version>
                  <mainClass>Test</mainClass>
                </jarResource>
              </jarResources>
            </jnlpFile>
          </jnlpFiles>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Here is the Maven trace:

C:\TEMP\webstart-test>mvn webstart:jnlp –e
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Desktop Components
[INFO]    task-segment: [webstart:jnlp] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing webstart:jnlp
[INFO] ------------------------------------------------------------------------
[INFO] Building Desktop Components
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\TEMP\webstart-test\src\main\resources
[INFO] [webstart:jnlp-download-servlet {execution: default}]
[INFO] No templateFilename found for launch2.jnlp. Will use the default template.
[INFO] No resources found in C:\TEMP\webstart-test\src\main\jnlp\resources
Downloading: http://repo1.maven.org/maven2/com/test/test/1.0/test-1.0.pom
[INFO] Unable to find resource 'com.test:test:pom:1.0' in repository central (http://repo1.maven.org/maven2)
No template specified Using default one.

***** Webstart JAR URL: jar:file:/C:/apache-maven-2.2.1/repo/org/codehaus/mojo/webstart/webstart-maven-plugin/1.0-alpha-2/webstart-maven-plugin-1.0-alpha-2.jar!
/
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\TEMP\webstart-test\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: C:\TEMP\webstart-test\target\test-1.0.jar
[INFO] [webstart:jnlp {execution: default-cli}]
[INFO] No resources found in C:\TEMP\webstart-test\src\main\jnlp\resources
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failure to run the plugin:
[INFO] ------------------------------------------------------------------------
[INFO] Trace

The trace follows

org.apache.maven.lifecycle.LifecycleExecutionException: Failure to run the plugin:
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:592)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Now the Caused by trace

Caused by: org.apache.maven.plugin.MojoExecutionException: Failure to run the plugin:
        at org.codehaus.mojo.webstart.AbstractJnlpMojo.execute(AbstractJnlpMojo.java:289)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        ... 17 more

Caused by: java.lang.NullPointerException
        at org.codehaus.mojo.webstart.AbstractJnlpMojo.execute(AbstractJnlpMojo.java:214)
        ... 19 more

And the final Maven trace

[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Fri Nov 13 11:16:54 GMT 2009
[INFO] Final Memory: 12M/22M
[INFO] ------------------------------------------------------------------------

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

乖乖哒 2024-08-18 05:49:47

这是 JNLP 的 mainClass 的问题

你需要这样的东西

<configuration>
   <jnlp>
      <mainClass>com.test.Test</mainClass>
   </jnlp>
<configuration>

This is problem with mainClass for JNLP

You need something like this

<configuration>
   <jnlp>
      <mainClass>com.test.Test</mainClass>
   </jnlp>
<configuration>
紅太極 2024-08-18 05:49:47

我确信这对您来说不再是问题,因为这个问题已经存在一年了。但是,为了完整起见......

我编辑了问题以使其可读。这向我们表明错误位于 AbstractJnlpMojo 的第 214 行。 查看最新版本源码第214行(上面的根本原因),我们可以看到这是因为你没有为JNLP指定main方法文件。

JNLP 不需要 jar 资源中刚刚指定的 main 方法类。 JNLP 标签中也需要它,如下所示。

    <configuration>
      <jnlp>
        <mainClass>com.test.Test</mainClass>
      </jnlp>
    </configuration>

由于代码已更改,如果您今天执行此操作,您将收到以下异常(更具可读性):

org.apache.maven.plugin.MojoExecutionException: 
  didn't find artifact with main class: null. Did you specify it? 

I'm sure this is no longer a problem for you, as the question is a year old. However, for the sake of completeness...

I've edited the question to make it readable. This shows us the error is on line 214 of AbstractJnlpMojo. Looking at the latest version source code on line 214 (the root cause above), we can see this is because you have not specified the main method for the JNLP file.

The JNLP doesn't need the main method class just specified in the jar resources. It also needs it in the JNLP tag, like this.

    <configuration>
      <jnlp>
        <mainClass>com.test.Test</mainClass>
      </jnlp>
    </configuration>

As the code has changed, if you did this today, you would get the following Exception (a bit more readable):

org.apache.maven.plugin.MojoExecutionException: 
  didn't find artifact with main class: null. Did you specify it? 
情痴 2024-08-18 05:49:47

为了解决这个问题:

未找到主类的工件:null。你指定了吗?

我必须创建一个多模块 Maven 项目,如下所示:

  • base-project
    • 主应用
    • 网络启动

然后在 webstart 的 pom 文件中,我将 main-app 作为依赖项包含在内。最后,从 webstart 目录中运行 mvn webstart:jnlp

For solving this issue:

didn't find artifact with main class: null. Did you specify it?

I had to create a multi-module maven project as follows:

  • base-project
    • main-app
    • webstart

Then inside webstart's pom file I included main-app as a dependency. Finally, run mvn webstart:jnlp from within webstart directory.

沙沙粒小 2024-08-18 05:49:47

我不认为它是你的依赖项没有找到,而是 C:\TEMP\webstart-test\src\main\jnlp\resources 中的一些文件,例如你的 jnlp 文件的 Velocity 模板?

I don't think its your dependencies that are not found, but rather some files in C:\TEMP\webstart-test\src\main\jnlp\resources, such as the Velocity template for your jnlp file maybe?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文