maven-resources-plugin 中奇怪的 NullPointerException

发布于 2024-11-25 23:43:16 字数 3509 浏览 2 评论 0原文

大约一天两次,我们在构建中遇到 NullPointerException:

[06:44:23]: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources (default-resources) on project spring-lib: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed. NullPointerException -> [Help 1]
[06:44:23]: org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources (default-resources) on project spring-lib: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed.
[06:44:23]: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
[06:44:23]: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[06:44:23]: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[06:44:23]: at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
[06:44:23]: at org.apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.java:167)
[06:44:23]: at org.apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.java:164)
[06:44:23]: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
[06:44:23]: at java.util.concurrent.FutureTask.run(FutureTask.java:138)
[06:44:23]: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
[06:44:23]: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
[06:44:23]: at java.util.concurrent.FutureTask.run(FutureTask.java:138)
[06:44:23]: at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[06:44:23]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[06:44:23]: at java.lang.Thread.run(Thread.java:619)
[06:44:23]: Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed.
[06:44:23]: at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
[06:44:23]: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
[06:44:23]: ... 13 more
[06:44:23]: Caused by: java.lang.NullPointerException
[06:44:23]: at java.util.ArrayList.<init>(ArrayList.java:131)
[06:44:23]: at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filteredFileExtension(DefaultMavenResourcesFiltering.java:115)
[06:44:23]: at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:264)
[06:44:23]: at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:310)
[06:44:23]: at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
[06:44:23]: ... 14 more

这是随机发生的,并且下一个构建不会失败。

我用谷歌搜索了这个失败并没有发现任何结果。我有这种直觉,这可能是由 maven-resources-plugin 中的并发问题引起的。

我们在 maven-resources-plugin 2.4.3 中遇到此错误,现在在 2.5 中出现此错误。我们的maven版本是3.0.3。

我们使用以下参数在 TeamCity 上执行构建:

Goals: install
Additional Maven command line parameters: -T 2C -e -P!releasex,integration 
-Dmaven.test.failure.ignore=true -Dmaven.test.error.ignore=true 
-Dmaven.test.haltafterfailure=false -Dmaven.junit.timeout=1000000
-DwarProject.packaging=jar

感谢您提供解决此问题的任何帮助。

About twice a day we get a NullPointerException in our build:

[06:44:23]: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources (default-resources) on project spring-lib: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed. NullPointerException -> [Help 1]
[06:44:23]: org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources (default-resources) on project spring-lib: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed.
[06:44:23]: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
[06:44:23]: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[06:44:23]: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[06:44:23]: at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
[06:44:23]: at org.apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.java:167)
[06:44:23]: at org.apache.maven.lifecycle.internal.LifecycleThreadedBuilder$1.call(LifecycleThreadedBuilder.java:164)
[06:44:23]: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
[06:44:23]: at java.util.concurrent.FutureTask.run(FutureTask.java:138)
[06:44:23]: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
[06:44:23]: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
[06:44:23]: at java.util.concurrent.FutureTask.run(FutureTask.java:138)
[06:44:23]: at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
[06:44:23]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[06:44:23]: at java.lang.Thread.run(Thread.java:619)
[06:44:23]: Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed.
[06:44:23]: at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
[06:44:23]: at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
[06:44:23]: ... 13 more
[06:44:23]: Caused by: java.lang.NullPointerException
[06:44:23]: at java.util.ArrayList.<init>(ArrayList.java:131)
[06:44:23]: at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filteredFileExtension(DefaultMavenResourcesFiltering.java:115)
[06:44:23]: at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:264)
[06:44:23]: at org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:310)
[06:44:23]: at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
[06:44:23]: ... 14 more

This comes at random times, and the next build doesn't fail.

I've googled for this failure and found nothing. I have this gut feeling that this may be caused by a concurrency issue in the maven-resources-plugin.

We got this error with maven-resources-plugin 2.4.3, and now with 2.5. Our maven version is 3.0.3.

We execute the build on TeamCity with the following parameters:

Goals: install
Additional Maven command line parameters: -T 2C -e -P!releasex,integration 
-Dmaven.test.failure.ignore=true -Dmaven.test.error.ignore=true 
-Dmaven.test.haltafterfailure=false -Dmaven.junit.timeout=1000000
-DwarProject.packaging=jar

Any sort of help for solving this issue is appreciated.

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

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

发布评论

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

评论(1

深海少女心 2024-12-02 23:43:16

尝试使用 -X 运行 Maven 并分析调试输出。这可能会有所帮助。至少对我来说,这种情况经常发生。

编辑:这是有问题的地方:

113  public boolean filteredFileExtension( String fileName, List userNonFilteredFileExtensions )
114 {
115 List nonFilteredFileExtensions = new ArrayList( getDefaultNonFilteredFileExtensions() );

getDefault..返回null。您是否以某种方式更改了 nonFilteredExts ?因为它们默认填充在此处:

63  // ------------------------------------------------
64 // Plexus lifecycle
65 // ------------------------------------------------
66 public void initialize()
67 throws InitializationException
68 {
69 // jpg,jpeg,gif,bmp,png
70 this.defaultNonFilteredFileExtensions = new ArrayList( 5 );
71 this.defaultNonFilteredFileExtensions.add( "jpg" );
72 this.defaultNonFilteredFileExtensions.add( "jpeg" );
73 this.defaultNonFilteredFileExtensions.add( "gif" );
74 this.defaultNonFilteredFileExtensions.add( "bmp" );
75 this.defaultNonFilteredFileExtensions.add( "png" );
76 }

由于您是并行构建的,因此这可能是竞争条件。您确实应该在 MRESOURCES 上提出问题。

Try to run maven with -X and analyze the debug output. This might help. At least for me it does very often.

Edit: This is the problematic spot:

113  public boolean filteredFileExtension( String fileName, List userNonFilteredFileExtensions )
114 {
115 List nonFilteredFileExtensions = new ArrayList( getDefaultNonFilteredFileExtensions() );

getDefault.. returns null. Did you change the nonFilteredExts somehow? Because they are populated by default here:

63  // ------------------------------------------------
64 // Plexus lifecycle
65 // ------------------------------------------------
66 public void initialize()
67 throws InitializationException
68 {
69 // jpg,jpeg,gif,bmp,png
70 this.defaultNonFilteredFileExtensions = new ArrayList( 5 );
71 this.defaultNonFilteredFileExtensions.add( "jpg" );
72 this.defaultNonFilteredFileExtensions.add( "jpeg" );
73 this.defaultNonFilteredFileExtensions.add( "gif" );
74 this.defaultNonFilteredFileExtensions.add( "bmp" );
75 this.defaultNonFilteredFileExtensions.add( "png" );
76 }

Since you are building in parallel, this might be a race condition. You should really raise an issue at MRESOURCES.

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