1

I want to integrate my maven java application with SonarQube5.4.

Using maven3.3.3 and MySQL5.7.12

Already SonarQube installed successfully and its running.

If i go to my project path in command prompt and run command mvn sonar:sonar, i'm getting the following error

[WARNING] Failed to retrieve plugin descriptor for org.codehaus.sonar:sonar-maven-plugin:2.4: 
Plugin org.codehaus.sonar:sonar-maven-plugin:2.4 or one of its dependencies could not be resolved: 
Failed to read artifact descriptor for org.codehaus.sonar:sonar-maven-plugin:jar:2.4
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/sonar-maven-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.codehaus.mojo:sonar-maven-plugin/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org
[ERROR] Error resolving version for plugin 'org.codehaus.mojo:sonar-maven-plugin' 
from the repositories [local (C:\Users\username\.m2\repository), 
central (https://repo.maven.apache.org/maven2)]: 
Plugin not found in any plugin repository -> [Help 1]

But if i go to my .m2 directory org/codehaus/mojo/sonar-maven-plugin i can find maven-metadata.xml. Also i can find sonar-maven-plugin-2.4.jar, sonar-maven-plugin-2.4.pom in org/codehaus/mojo/sonar-maven-plugin/2.4 folders

I'm confused, these are available in the local repository then its trying to download?

Help me

Please find my pom.xml below

  <?xml version="1.0"?>

<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mycompany.server</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <artifactId>MyProject</artifactId>
    <packaging>war</packaging>
    <name>MyProject</name>

    <properties>
        <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
        <!-- External Dependencies versions -->
        <build-helper-maven-plugin.version>1.7</build-helper-maven-plugin.version>
        <hibernate.jpa.version>1.0.1.Final</hibernate.jpa.version>
        <hibernate.validator.version>4.3.1.Final</hibernate.validator.version>
        <hibernate.version>4.2.6.Final</hibernate.version>
        <java.version>1.7</java.version>
        <javax.servlet.jsp.version>2.1</javax.servlet.jsp.version>
        <jaxb.version>2.2.4</jaxb.version>
        <jsp-api.version>2.2</jsp-api.version>
        <jstl.version>1.2</jstl.version>
        <junit.version>4.11</junit.version>
        <log4j.version>1.2.15</log4j.version>
        <slf4j.log4j.version>1.6.1</slf4j.log4j.version>
        <maven.assembly.plugin>2.3</maven.assembly.plugin>
        <maven.clean.plugin>2.5</maven.clean.plugin>
        <maven.compiler.plugin>2.0.2</maven.compiler.plugin>
        <maven.dependency.plugin>2.4</maven.dependency.plugin>
        <maven.deploy.plugin>2.7</maven.deploy.plugin>
        <maven.eclipse.plugin>2.9</maven.eclipse.plugin>
        <maven.exec.plugin>1.2.1</maven.exec.plugin>
        <maven.install.plugin>2.3.1</maven.install.plugin>
        <maven.jar.plugin>2.4</maven.jar.plugin>
        <maven.plugin.plugin>3.1</maven.plugin.plugin>
        <maven.surefire.plugin>2.12</maven.surefire.plugin>
        <maven.tomcat.plugin>2.0-beta-1</maven.tomcat.plugin>
        <maven.version.range>[2.2.1,3.1.0)</maven.version.range>
        <maven.versions.plugin>1.3.1</maven.versions.plugin>
        <maven.war.plugin>2.2</maven.war.plugin>
        <oracle.version>6</oracle.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <servlet-api.version>3.0.1</servlet-api.version>
        <spring.version>4.0.6.RELEASE</spring.version>
        <apache.core.http>4.3.2</apache.core.http>
        <apache.http.client>4.3.4</apache.http.client>
        <json.lib.jdk5>2.4</json.lib.jdk5>
        <signpost.commonhttp4>1.2.1.1</signpost.commonhttp4>
        <signpost.core>1.2.1.1</signpost.core>
        <json.version>20140107</json.version>
        <google.oauth.client>1.15.0-rc</google.oauth.client>
        <org.restlet.org>2.0</org.restlet.org>
        <org.restlet>2.0.8</org.restlet>
    </properties>

    <build>

        <plugins>
            <plugin>
                <groupId>org.codehaus.sonar</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                <version>2.4</version>

            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>

                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>

                <configuration>
                    <warName>MyPoriject</warName>
                    <webappDirectory>${webappDirectory}</webappDirectory>

                    <webResources>

                        <resource>
                            <filtering>true</filtering>
                            <directory>src/main/webapp</directory>

                            <includes>
                                <include>**/*.xml</include>
                            </includes>
                        </resource>
                    </webResources>

                    <archive>

                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>${commons.beanutils.version}</version>

            <exclusions>

                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>${commons.cli.version}</version>

            <exclusions>

                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${servlet-api.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>${jsp-api.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>${validation-api.version}</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${hibernate.validator.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-exec</artifactId>
            <version>${commons.exec.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>

            <exclusions>

                <exclusion>
                    <groupId>quartz</groupId>
                    <artifactId>quartz</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>${jackson.version}</version>
        </dependency>
            <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>

    </dependencies>
</project>
G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
Gnik
  • 7,120
  • 20
  • 79
  • 129
  • try to replace the plugin of sonar by this : org.codehaus.sonar sonar-maven3-plugin 2.4 – Hohenheim Apr 20 '16 at 10:58
  • Done. Still same error – Gnik Apr 20 '16 at 11:07
  • even with `mvn clean install` ? – Hohenheim Apr 20 '16 at 11:10
  • let me try this and update you. – Gnik Apr 20 '16 at 12:42
  • 1
    Also, you shouldn't use `org.codehaus.sonar` (explained [here](http://docs.sonarqube.org/display/HOME/Frequently+Asked+Questions)) but [follow the guide](http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven#AnalyzingwithSonarQubeScannerforMaven-ProjectanalyzedwithMaven3) instead: `org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1` . – Nicolas B. Apr 20 '16 at 16:09

1 Answers1

0

have you tried to remove org/codehaus/mojo/sonar-maven-plugin from you local repo and start maven again?

UKoehler
  • 131
  • 7
  • Yes removed it and run the maven. Still getting the same error. – Gnik Apr 20 '16 at 11:04
  • have you tried current version of the plugin? org.codehaus.mojo sonar-maven-plugin 3.0.1 – UKoehler Apr 20 '16 at 13:39
  • if it still not working, i think you have a network connection problem , maven could not download the artifact. ...... Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/sonar-maven-plugin/maven-metadata.xml [WARNING] Could not transfer metadata org.codehaus.mojo:sonar-maven-plugin/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org [ERROR] Error resolving version for plugin 'org.codehaus.mojo:sonar-maven-plugin' – UKoehler Apr 20 '16 at 14:02
  • @UKoehler what you said is false : if he had an eror with his connection or a problem with proxy he would have a message error like this `Error transferring file: Connection refused: connect` – Hohenheim Apr 20 '16 at 14:20