希望有人可以帮助我解决这个奇怪的问题。我正在尝试运行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] ------------------------------------------------------------------------
答案 0 :(得分:1)
这是JNLP的 mainClass 的问题
你需要这样的东西
<configuration>
<jnlp>
<mainClass>com.test.Test</mainClass>
</jnlp>
<configuration>
答案 1 :(得分:0)
我确信这不再是你的问题,因为这个问题已经有一年了。但是,为了完整起见......
我编辑了这个问题,使其具有可读性。这向我们展示了错误是在AbstractJnlpMojo的第214行。第214行Looking at the latest version source code(上面的根本原因),我们可以看到这是因为你没有为JNLP文件指定主方法。
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?
答案 2 :(得分:0)
解决此问题:
没有找到主类的工件:null。你有没说明呢?
我必须按如下方式创建一个多模块maven项目:
然后在webstart
的pom文件中,我将main-app
作为依赖项。最后,从mvn webstart:jnlp
目录中运行webstart
。
答案 3 :(得分:-1)
我不认为你的依赖是没有找到的,而是C:\ TEMP \ webstart-test \ src \ main \ jnlp \ resources中的一些文件,比如你的jnlp文件的Velocity模板可能吗? / p>