Friday, June 10, 2011

Java - Sonar: Fix for "POM 'org.codehaus.mojo:sonar-maven-plugin' not found in repository"

This posting is meant for Java developers who has configured the code quality/metrics tool sonar and if it throws "Reason: POM 'org.codehaus.mojo:sonar-maven-plugin' not found in repository: Unable to download the artifact from any repository " while executing "mvn sonar:sonar" to publish the code quality metrics.

Reason for failure: This issue is related to maven. You can read about the actual issue here.

Fix: I'd recommend multiple work-around and try which ever works for you.

1. Try this command : 'mvn -U sonar:sonar' - This will update the local repo files. [OR]


2. Goto your Maven repo home and delete 'mojo' folder from org/codehaus/mojo(in windows:C:\Documents and Settings\\.m2\repository\org\codehaus\mojo) and rerun the sonar(mvn sonar:sonar). [OR]

3. Add the following plugin into your pom.xml and it will solve the issue(In the below code, you can provide the version you are interested in. You may go to Maven local repo and this file :org\codehaus\mojo\sonar-maven-plugin\maven-metadata-central.xml and see the version you are interested in).
        <plugin>
<groupid>org.codehaus.mojo</groupid>
<artifactid>sonar-maven-plugin</artifactid>
<version>1.0-beta-2</version>
</plugin>




Below is the exception message thrown while executing maven.

Project ID: org.codehaus.mojo:sonar-maven-plugin
Reason: POM 'org.codehaus.mojo:sonar-maven-plugin' not found in repository: Unable to download the artifact from any repository
org.codehaus.mojo:sonar-maven-plugin:pom:2.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.codehaus.mojo:sonar-maven-plugin
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unable to build project information for plugin 'org.codehaus.mojo:sonar-maven-plugin': POM 'org.codehaus.mojo:sonar-maven-plugin' not found in repository: Unable to download the artifact from any repository
org.codehaus.mojo:sonar-maven-plugin:pom:2.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)

for project org.codehaus.mojo:sonar-maven-plugin
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1557)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
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.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.InvalidPluginException: Unable to build project information for plugin 'org.codehaus.mojo:sonar-maven-plugin': POM 'org.codehaus.mojo:sonar-maven-plugin' not found in repository: Unable to download the artifact from any repository

 

1 comment: