Странное исключение NullPointerException в maven-resources-plugin - PullRequest
4 голосов
/ 25 июля 2011

Примерно два раза в день мы получаем исключение 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.

Мы получили эту ошибку с помощью 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

Любая помощь в решении этой проблемы приветствуется.

1 Ответ

2 голосов
/ 25 июля 2011

Попробуйте запустить maven с -X и проанализируйте результаты отладки.Это может помочь.По крайней мере, для меня это происходит очень часто.

Редактировать: Это проблемное место:

<a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#113" rel="nofollow">113</a>  <b>public</b> <b>boolean</b> filteredFileExtension( <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/String.java#String" rel="nofollow" title="java.lang.String">String</a> fileName, <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/List.java#List" rel="nofollow" title="java.util.List">List</a> userNonFilteredFileExtensions )<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#114" rel="nofollow">114</a>  {<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#115" rel="nofollow">115</a>      <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/List.java#List" rel="nofollow" title="java.util.List">List</a> nonFilteredFileExtensions = <b>new</b> <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/ArrayList.java#ArrayList" rel="nofollow" title="java.util.ArrayList">ArrayList</a>( <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#DefaultMavenResourcesFiltering.getDefaultNonFilteredFileExtensions%28%29" rel="nofollow" title="org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.getDefaultNonFilteredFileExtensions() : List">getDefaultNonFilteredFileExtensions</a>() );<br/>

getDefault .. возвращает null.Вы как-то изменили nonFilteredExts?Поскольку они заполняются здесь по умолчанию:

<a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#63" rel="nofollow">63</a>  // ------------------------------------------------<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#64" rel="nofollow">64</a>  //  Plexus lifecycle<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#65" rel="nofollow">65</a>  // ------------------------------------------------<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#66" rel="nofollow">66</a>  <b>public</b> <b>void</b> initialize()<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#67" rel="nofollow">67</a>      <b>throws</b> <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.codehaus.plexus/plexus-container-default/1.0-alpha-9-stable-1/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.java#InitializationException" rel="nofollow" title="org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException">InitializationException</a><br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#68" rel="nofollow">68</a>  {<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#69" rel="nofollow">69</a>      // jpg,jpeg,gif,bmp,png<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#70" rel="nofollow">70</a>      <b>this</b>.defaultNonFilteredFileExtensions = <b>new</b> <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/ArrayList.java#ArrayList" rel="nofollow" title="java.util.ArrayList">ArrayList</a>( 5 );<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#71" rel="nofollow">71</a>      <b>this</b>.defaultNonFilteredFileExtensions.<a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/List.java#List.add%28java.lang.Object%29" rel="nofollow" title="java.util.List.add(java.lang.Object) : boolean">add</a>( "jpg" );<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#72" rel="nofollow">72</a>      <b>this</b>.defaultNonFilteredFileExtensions.<a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/List.java#List.add%28java.lang.Object%29" rel="nofollow" title="java.util.List.add(java.lang.Object) : boolean">add</a>( "jpeg" );<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#73" rel="nofollow">73</a>      <b>this</b>.defaultNonFilteredFileExtensions.<a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/List.java#List.add%28java.lang.Object%29" rel="nofollow" title="java.util.List.add(java.lang.Object) : boolean">add</a>( "gif" );<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#74" rel="nofollow">74</a>      <b>this</b>.defaultNonFilteredFileExtensions.<a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/List.java#List.add%28java.lang.Object%29" rel="nofollow" title="java.util.List.add(java.lang.Object) : boolean">add</a>( "bmp" );<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#75" rel="nofollow">75</a>      <b>this</b>.defaultNonFilteredFileExtensions.<a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/List.java#List.add%28java.lang.Object%29" rel="nofollow" title="java.util.List.add(java.lang.Object) : boolean">add</a>( "png" );<br/><a href="http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven.shared/maven-filtering/1.0/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java#76" rel="nofollow">76</a>  }    <br/><br/>

Поскольку вы строите параллельно, это может быть условием гонки.Вы должны действительно поднять проблему в MRESOURCES .

...