Source Tree Directory
The source directory tree has to match the package declarations.
Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: org.sonar.squid.api.AnalysisException: Got an exception - org.so nar.squid.api.AnalysisException: The source directory does not correspond to the package declaration com.mycompany.mypackage, file : ..\src\MyClass.java ...
Analyzing with Maven
What is the difference between org.codehaus.mojo:sonar-maven-plugin and org.codehaus.sonar:sonar-maven-plugin?
Here is the rational: Sonar needs a Maven plugin to perform analysis of your project. This plugin is part of Sonar project so the name of this plugin is org.codehaus.sonar:sonar-maven-plugin because codehaus is hosting the project. Each time there is a new version of Sonar, there is a new version of the Sonar plugin. For a given version of the Sonar server, you MUST run the same version of the Sonar Maven plugin. It means that you would have to run
Most of the time you need latest version of the boostrap plugin, so no need to fix its version in your pom, except if you want to test a particular version (an old one or a SNAPSHOT for example).
Maven mirrors: the maven plugin fails to resolve org.codehaus.sonar.runtime.* dependencies
This issue occurs when using a Sonar version prior to 2.2. To fix it, it's recommended to upgrade Sonar and the maven plugin to version 1.0-beta-2 (for Maven 2 projects) or 2.0-beta-2 (for Maven 3 projects).
If you have Maven version 2.0.9 or higher, just change the value of <mirrorOf> by
- Or configure your central maven repository (eg. Nexus, Archiva or Artifactory) to use the Sonar internal repository (http://sonar:9000/deploy/maven).
Error resolving version for 'org.codehaus.mojo:sonar-maven-plugin': Plugin requires Maven version 3.0
This error means that you're using Maven 2.0.10 or Maven 2.0.11. Due to SONAR-1994, you must add the following lines to the pom.xml file :
<build> <pluginManagement> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>1.0</version> </plugin> </plugins> </pluginManagement> </build>
Cobertura exception on Linux System while accessing the cobertura.ser file
When reading the cobertura.ser file, the Cobertura Maven plugin tries to get a lock on that file. This locking mechanism generates an exception on Linux Systems SONAR-172.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4.3</version> <configuration> <systemProperties> <property> <name>cobertura.use.java.nio</name> <value>false</value> </property> </systemProperties> </configuration> </plugin>
The plugin 'org.apache.maven.plugins:maven-sonar-plugin' does not exist or no valid version could be found
If you get this error message after launching the maven command line "mvn sonar:sonar" add the "-U" parameter to the command line. Maven will then update its local repository with the latest version of the Sonar Maven plugin.
If adding the "-U" parameter doesn't fix your issue, you've certainly encountered Maven bug MNG-4001. The only known workaround is to delete the org\codehaus\mojo directory in your local Maven repository. Of course, if your local Maven repository is synchronized with a repository manager like Nexus, this operation must be also done on the repository manager side.
Maven fails with an OutOfMemoryError
Increase the maven available memory by setting the environment variable :
Maven fails with a SecurityException
The message of the root exception is
You must also sign Sonar libraries in your Maven repository or used unsigned CGLIB library.
Maven fails with a NoClassDefFoundError
Typically error message looks like :
- Your Maven repository (local or remote) contains corrupted JARs.
- You have exceeded limit of open files - see http://markmail.org/message/wvfvafgrga5b6tnd.
Maven fails because of Maven Enforcer violations
You have to add the parameter -Denforcer.skip=true to the Maven command-line.
Failed to resolve stax2-api artifact
The following error occurs when using Maven Archiva 1.1. It must be upgraded to 1.2.1.
[INFO] Failed to resolve artifact. No versions are present in the repository for the artifact with a range [3.0.0,3.1.0) org.codehaus.woodstox:stax2-api:jar:null
FindBugs fails on timeout
See SONAR-1439. Findbugs fails with the following logs :
Add the findbugs-maven-plugin to the plugins section of the pom and configure the parameter "timeout".
0% code coverage reported whereas unit tests are correctly executed
This problem occurs when using the Maven Cobertura Plugin and a special configuration of the Maven Surefire Plugin preventing unit tests to be forked. This problem can be solved by removing the line "<forkMode>never</forkMode>" in the Maven configuration file (see SONAR-1445 and MCOBERTURA-70).
My project only builds with JDK1.4
As Sonar can only run with JDK1.5 or higher, some configuration should be added to the pom.xml to indicate that the project requires JDK1.4: