NullPointerException archetype:crawl

青春壹個敷衍的年華 提交于 2019-12-25 01:44:11

问题


I'm trying to discover the archtypes installed in my local repository. I read this is possible run the following command:

mvn archetype:crawl

Now when I run this command I get this error:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:crawl (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:2.2:crawl failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:crawl (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:2.2:crawl failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
    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.PluginExecutionException: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:2.2:crawl failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: java.lang.NullPointerException
    at org.apache.maven.archetype.common.DefaultArchetypeArtifactManager.closeZipFile(DefaultArchetypeArtifactManager.java:584)
    at org.apache.maven.archetype.common.DefaultArchetypeArtifactManager.isFileSetArchetype(DefaultArchetypeArtifactManager.java:196)
    at org.apache.maven.archetype.repositorycrawler.DefaultRepositoryCrawler.crawl(DefaultRepositoryCrawler.java:72)
    at org.apache.maven.archetype.mojos.CrawlRepositoryMojo.execute(CrawlRepositoryMojo.java:70)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    ... 20 more

回答1:


I got the same issue. A null pointer with an "error in opening zip file" just before the build failure. I fixed it by deleting the file in question which was a jar that was corrupted in my local maven repository (Got an error when trying to open it with winrar).




回答2:


This seems to be a known bug of older maven-archetype-plugin versions. Try specifying the last stable plugin version explicitly:

mvn org.apache.maven.plugins:maven-archetype-plugin:2.2:crawl

If the bug is still there, try checking file permissions in your local maven repository folder. There should be at least "read" permission on all jar files inside it.

If you run maven with the -X switch you will probably get the real cause of the problem in the console log just before the BUILD FAILURE message. Something like [DEBUG] org.apache.maven.archetype.exception.UnknownArchetype: java.io.FileNotFoundException: /path/to/file.jar (Access denied)



来源:https://stackoverflow.com/questions/22833438/nullpointerexception-archetypecrawl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!