Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn idea:idea throws a NullPointerException

While I am trying to execute mvn idea:idea -X in my project. I am facing a peculiar issue -

> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-idea-plugin:2.2.1:idea (default-cli) on
> project test-model: Execution default-cli of goal
> org.apache.maven.plugins:maven-idea-plugin:2.2.1:idea failed.
> NullPointerException -> [Help 1]
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
> execute goal org.apache.maven.plugins:maven-idea-plugin:2.2.1:idea
> (default-cli) on project document-model: Execution default-cli of goal
> org.apache.maven.plugins:maven-idea-plugin:2.2.1:idea failed.
>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
>         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:116)
>         at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
>         at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
>         at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
>         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
>         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:497)
>         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-idea-plugin:2.2.1:idea failed.
>         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
>         at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
>         ... 20 more Caused by: java.lang.NullPointerException
>         at org.apache.maven.repository.legacy.DefaultWagonManager.connectWagon(DefaultWagonManager.java:244)
>         at org.apache.maven.repository.legacy.DefaultWagonManager.getRemoteFile(DefaultWagonManager.java:346)
>         at org.apache.maven.repository.legacy.DefaultWagonManager.getArtifact(DefaultWagonManager.java:110)
>         at org.apache.maven.repository.legacy.DefaultWagonManager.getArtifact(DefaultWagonManager.java:163)
>         at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:155)
>         at org.apache.maven.plugin.idea.IdeaModuleMojo.resolveClassifiedArtifact(IdeaModuleMojo.java:966)
>         at org.apache.maven.plugin.idea.IdeaModuleMojo.resolveClassifier(IdeaModuleMojo.java:929)
>         at org.apache.maven.plugin.idea.IdeaModuleMojo.rewriteDependencies(IdeaModuleMojo.java:587)
>         at org.apache.maven.plugin.idea.IdeaModuleMojo.rewriteModule(IdeaModuleMojo.java:409)
>         at org.apache.maven.plugin.idea.IdeaMojo.rewriteModule(IdeaMojo.java:220)
>         at org.apache.maven.plugin.idea.IdeaMojo.execute(IdeaMojo.java:200)
>         at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
>         ... 21 more [ERROR]  [ERROR]  [ERROR] For more information about the errors and possible solutions, please read the following
> articles: [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

The link here reads -

This error is reported in case the execution of a plugin failed due to some unforeseen event. For example, uncatched runtime exceptions caused by the plugin will raise this error. You should report this problem to the maintainer of the plugin.

Being not sure of the maintainer either, seeking some help here on SO.


Update 1 Following the steps mentioned by @A_Di-Matteo in the answer, I can figure out that the failure occurs at the step

mvn idea:module

for me with a similar stack trace

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-idea-plugin:2.2.1:module (default-cli) on project core: Execution default-cli of goal org.apache.maven.plugins:maven-idea-plugin:2.2.1:module failed. NullPointerException

Taking this to the important point again, is there a way to fix it?

like image 772
Naman Avatar asked Sep 03 '16 08:09

Naman


1 Answers

The maven-idea-plugin is retired and not maintained any longer since 2013 (actually inactive since 2008), hence any possible incompatibility with new versions of the IDE would block its usage.

If for any reason you still seek help by the idea:idea goal, getting error, you can try a different procedure:

mvn idea:clean
mvn idea:project    ---> it will create the .ipr file (core project info)
mvn idea:module     ---> it will create the .iml file (library info for the module)
mvn idea:workspace  ---> it will create the .iws file (personal workspace info)

The last three command would actually already be executed automatically by idea:idea, but they may help you further to check at which point the error arise and hopefully further hints for troubleshooting. However, all of these files are considered legacy files by the IDE, hence once again this is not the ideal procedure.

However, again, this could be troublesome: the plugin is most probably not compatible anymore with newer versions of the IDE.

If importing directly the parent pom.xml file doesn't import the project, then:

  • You could import the project as a generic Java project, then convert it to Maven project
  • alternatively (as worst case scenario) you may create a new Maven project in the IDE and step by step (copy&paste) re-create the one which was impossible to import: something will most probably come up as the issue or it would simply work as expected.
like image 71
A_Di-Matteo Avatar answered Oct 15 '22 06:10

A_Di-Matteo