7

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?

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
Naman
  • 27,789
  • 26
  • 218
  • 353
  • 1
    Have you tried importing the parent POM in IntelliJ, instead of using Maven to create project metadata? IntelliJ has seamless support for Maven projects, so why not use it? ;) – Bastien Jansen Sep 08 '16 at 07:55
  • @BastienJansen - am already using that, guess it doesn't help. – Naman Sep 08 '16 at 10:24

1 Answers1

14

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.
Community
  • 1
  • 1
A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
  • thanks that helps narrow down, update on question. But still looking for the solution to it better than simply copying into another project. – Naman Sep 16 '16 at 05:17
  • @nullpointer ok, it failed on `idea:module`, but then did `idea:workspace` work? Moreover, did you try to import it having already the `.ipr` file generated? And what about importing it as a generic Java project, then [convert it to Maven](http://stackoverflow.com/questions/7642456/intellij-convert-a-java-project-module-into-a-maven-project-module)? – A_Di-Matteo Sep 16 '16 at 07:01
  • `idea:workspace` executed successfully. How would importing a project as generic and converting help? Also it wouldn't be practical to do it for all the projects I have. Isn't it? – Naman Sep 19 '16 at 04:30
  • @nullpointer did you then try to import it with `idea:project` and `idea:workspace` successful? Conversion could help towards troubleshooting the initial problem (you may get some hints, further errors or simply compare the generated files by the IDE with the ones you had, and so on). – A_Di-Matteo Sep 19 '16 at 07:14
  • could you narrow down to which direction are we trying to move in? Since as I said it's not feasible to convert all the projects. Just for info, I tried that with one of the projects. But I don't see how it's helping here. – Naman Sep 21 '16 at 03:23
  • @nullpointer then I don't understand the overall process. Is this part of an automated script across several projects? Afterwards, these projects would anyway be imported one by one (manually) to the IDE, right? – A_Di-Matteo Sep 21 '16 at 15:47
  • they are already there(imported), why would I redo all of that? It's just that `mvn idea:idea` does not work when I would want to re-generate the files of any project. – Naman Sep 21 '16 at 15:52
  • But it would generate old/retired/incompatible files, you should not invoke it on the latest version of the IDE, that's the whole point of the answer. why do you need to do so? – A_Di-Matteo Sep 21 '16 at 15:59
  • Okay in that case if I want to regenerate the project files for IDE. Do I end with the only option of re-importing the project? Because it seems like IDEA has been making my life difficult while working on projects. – Naman Sep 21 '16 at 16:42
  • @nullpointer as pointed out in the question, this plugin will generate [legacy files](https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems) and I'm sure you don't want to rely on legacy files nor on a retired plugin with partially working goals. Why is the IDE complicating your life? what's kind of issues are you having with it? – A_Di-Matteo Sep 21 '16 at 21:14