问题
I am trying to get sonar to work for a project with a quality profile that includes Findbugs rules.
However when analyzing the project the sonar anttask chrashes with the following error:
Caused by: java.io.IOException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
at edu.umd.cs.findbugs.filter.Filter.<init>(Filter.java:134)
at edu.umd.cs.findbugs.FindBugs.configureFilter(FindBugs.java:516)
at edu.umd.cs.findbugs.FindBugs2.addFilter(FindBugs2.java:374)
at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:136)
... 50 more
on this project the dependencies are resolved with ivy, and has no dependencies on libraries like xerces and xalan. Also i understood that xerces is included included in the JVM and is always a pleasure to deal with...
i've tried to add all sorts of dependencies to use for the sonar.libraries property but with no effect adding the local JRE libs also doesnt seem to have much effect.
How do i get this findbugs analysis to run (in a machine independent way)?
(Sonar version: 4.4, findbugs3 plugin)
Update: I just found out the source of the conflict is having a target earlier in the build, removing it fixes it. Ofcourse i very much like to keep my ivy report as well, so the question is still how do i get this to work...?
回答1:
After upgrading our sonar to v4.4 and changing Sonar's Quality profile from 'Sonar way' (Java) to 'Sonar way with Findbugs' I came accross this same exception complaining about the SAX2 driving:
Can not execute SonarQube analysis: Can not execute Find bugs: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
I got around it by adding the driver to my maven command:
Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.SAXParser
Bellow was my actual maven command to clean, compile, run test, analyse code and upload stats to sonar (having the fix in the command line also meets you non machine specific preference fix and requires no change to your source code)
$ mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.fai
lure.ignore=true -Dorg.xml.sax.driver=com.sun.org.apache.xerces.internal.parsers.
SAXParser sonar:sonar
回答2:
Our Solution for
Can not execute Findbugs: SAX2 driver class org.apache.xerces.parsers.SAXParser
is not to use
mvn clean install sonar:sonar
in one command, but to invoke sonar in a seperate step
mvn clean install
mvn sonar:sonar
回答3:
This might solve the issue: Download xerces-2.9.0.jar from:
http://www.java2s.com/Code/Jar/x/Downloadxercesjar.htm
Add this jar to (sonar root folder)\extensions\plugins
Try this command in the desired folder
mvn clean install sonar:sonar
Good luck
来源:https://stackoverflow.com/questions/25872710/sonar-xerces-conflict-findbugs-and-ivyreport