Wednesday 7 November 2012

Failed to execute goal org.apache.maven.plugins:maven-install-plugin:... (Access is denied)

This is the backporting of a question I asked on StackOverflow. I also provided the solution/workaround to it.

Issue

I was getting the following error when compiling a maven project with NetBeans:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-install-plugin:2.3.1:install
(default-install) on project Plasma:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:\...\.m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:
Failed to execute goal
org.apache.maven.plugins:maven-install-plugin:2.3.1:install
(default-install) on project Plasma:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:\...\.m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:203)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
  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:316)
  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)
  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)
  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)
  at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
  at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by:
org.apache.maven.plugin.MojoExecutionException:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:\...\.m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied)
  at org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:139)
  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
... 19 more Caused by:
  org.apache.maven.artifact.installer.ArtifactInstallationException:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:\...\.m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied)
  at org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:110)
  at org.apache.maven.plugin.install.InstallMojo.execute(InstallMojo.java:103)
... 21 more Caused by:
  org.sonatype.aether.installation.InstallationException:
Failed to install artifact
net.dwst:Plasma:jar:1.0.0:
C:\...\.m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied)
  at org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:279)
  at org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:190)
  at org.sonatype.aether.impl.internal.DefaultRepositorySystem.install(DefaultRepositorySystem.java:322)
  at org.apache.maven.artifact.installer.DefaultArtifactInstaller.install(DefaultArtifactInstaller.java:106)
... 22 more Caused by:
  java.io.FileNotFoundException:
C:\...\.m2\repository\net\dwst\Plasma\1.0.0\Plasma-1.0.0.jar
(Access is denied)
  at java.io.FileOutputStream.open(Native Method)
  at java.io.FileOutputStream.<init>(FileOutputStream.java:179
  at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
  at org.sonatype.aether.impl.internal.DefaultFileProcessor.copy(DefaultFileProcessor.java:120)
  at org.sonatype.aether.impl.internal.DefaultInstaller.install(DefaultInstaller.java:255)
... 25 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/MojoExecutionException
A workaround was to delete the .m2 content, but the issue would come back from time to time.

Solution

To solve the issue once for all, one has to delete the content of .m2 and re-install NetBeans from scratch.

No comments:

Post a Comment