Sonar

Sonar FindBugs plugin fails on EAR projects with sources

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6, 1.7, 1.8, 1.9
  • Fix Version/s: 1.9.1
  • Component/s: Findbugs
  • Labels:
    None
  • Number of attachments :
    0

Description

When FB doesn't find anything wrong it doesn't create the findbugs.xml.

Resulting in case of -Dsonar.reuse=false

[INFO] Building App
[INFO] task-segment: [org.codehaus.sonar:sonar-core-maven-plugin:1.6-SNAPSHOT:prepare]
[INFO] ------------------------------------------------------------------------
[INFO] [sonar-core:prepare]
[ERROR] Cannot execute the command org.codehaus.sonar:sonar-core-maven-plugin:1.6-SNAPSHOT:prepare
java.lang.RuntimeException: Findbugs needs sources to be compiled. Please edit pom.xml to set the <ouputDirectory>
node and build before executing sonar.
at org.sonar.plugins.findbugs.FindbugsMavenPluginHandler.configureClassesDir(FindbugsMavenPluginHandler.ja
va:85)
at org.sonar.plugins.findbugs.FindbugsMavenPluginHandler.configurePlugin(FindbugsMavenPluginHandler.java:6
6)
at org.sonar.plugins.api.maven.AbstractMavenPluginHandler.configure(AbstractMavenPluginHandler.java:29)
at org.sonar.maven.PrepareMojo.prepareMavenPlugin(PrepareMojo.java:40)
at org.sonar.maven.PrepareMojo.doExecute(PrepareMojo.java:35)
at org.sonar.maven.CoreMojo.execute(CoreMojo.java:129)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)

And in case of -Dsonar.reuse=true

[INFO] Building App
[INFO] task-segment: [org.codehaus.sonar:sonar-core-maven-plugin:1.6-SNAPSHOT:collect]
[INFO] ------------------------------------------------------------------------
[INFO] [sonar-core:collect]
[INFO] Starting class org.sonar.plugins.findbugs.FindbugsMavenCollector
[ERROR] Cannot execute the command org.codehaus.sonar:sonar-core-maven-plugin:1.6-SNAPSHOT:collect
java.lang.NullPointerException
at org.sonar.plugins.api.maven.xml.XpathParser.parse(XpathParser.java:86)
at org.sonar.plugins.api.maven.AbstractViolationsXmlParser.collect(AbstractViolationsXmlParser.java:62)
at org.sonar.plugins.findbugs.FindbugsMavenCollector.collect(FindbugsMavenCollector.java:67)
at org.sonar.maven.CollectMojo.doExecute(CollectMojo.java:49)
at org.sonar.maven.CoreMojo.execute(CoreMojo.java:129)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)

Issue Links

Activity

Hide
Simon Brandhof added a comment -

Hi Jane,

I can not reproduce the issue. The file findbugs.xml is created when no violations :

<?xml version="1.0" encoding="UTF-8"?>
<BugCollection version="1.3.2" threshold="Low" effort="Max" >
<Errors>
</Errors>
<Project>
<SrcDir>/Users/sbrandhof/projects/sonar/trunk/tests/integration/reference-projects/SONAR-594-no-violations/src/main/java</SrcDir>
</Project>
</BugCollection>

Could you check that the issue does not occur on non-patched sonar ?
Thank you

Show
Simon Brandhof added a comment - Hi Jane, I can not reproduce the issue. The file findbugs.xml is created when no violations :
<?xml version="1.0" encoding="UTF-8"?>
<BugCollection version="1.3.2" threshold="Low" effort="Max" >
<Errors>
</Errors>
<Project>
<SrcDir>/Users/sbrandhof/projects/sonar/trunk/tests/integration/reference-projects/SONAR-594-no-violations/src/main/java</SrcDir>
</Project>
</BugCollection>
Could you check that the issue does not occur on non-patched sonar ? Thank you
Hide
Jene Jasper added a comment -

Create a simple project with mvn archetype:create -DgroupId=nl.abz -DartifactId=simple

Change its pom.xml packaging type to ear.

Run mvn clean install site
followed by mvn org.codehaus.sonar:sonar-maven-plugin:1.6-SNAPSHOT:sonar -D...

First assumption about Findbugs was wrong. It never generates a report when packaging is ear.

Show
Jene Jasper added a comment - Create a simple project with mvn archetype:create -DgroupId=nl.abz -DartifactId=simple Change its pom.xml packaging type to ear. Run mvn clean install site followed by mvn org.codehaus.sonar:sonar-maven-plugin:1.6-SNAPSHOT:sonar -D... First assumption about Findbugs was wrong. It never generates a report when packaging is ear.
Hide
Simon Brandhof added a comment - - edited

Hi Jene,
Can you confirm that your EAR project does not have any Java sources ? Indeed they are not compiled by maven-ear-plugin, an EAR only embedds libraries (JAR, WAR, ...).
Thank you

Show
Simon Brandhof added a comment - - edited Hi Jene, Can you confirm that your EAR project does not have any Java sources ? Indeed they are not compiled by maven-ear-plugin, an EAR only embedds libraries (JAR, WAR, ...). Thank you
Hide
Jene Jasper added a comment -

As you can see by the way I reproduced the problem, I ran into an EAR project, which had one probably stray App.java source. When the source was deleted the problem did no longer occur, because the Sonar plugin detected no java sources.

Because both CS and PMD still checked the stray source and FB didn't, I left the issue open.

And indeed this situation is not likely, but then again the system could be more robust by handling this situation. Because I only figured out the real problem, when I looked at the Sonar code and found the check for an existing java sources. Alternatively close this issue as a wont fix just for future reference for users who run into the same problem.

Show
Jene Jasper added a comment - As you can see by the way I reproduced the problem, I ran into an EAR project, which had one probably stray App.java source. When the source was deleted the problem did no longer occur, because the Sonar plugin detected no java sources. Because both CS and PMD still checked the stray source and FB didn't, I left the issue open. And indeed this situation is not likely, but then again the system could be more robust by handling this situation. Because I only figured out the real problem, when I looked at the Sonar code and found the check for an existing java sources. Alternatively close this issue as a wont fix just for future reference for users who run into the same problem.
Hide
Simon Brandhof added a comment -

I think that SONAR-749 (and transitively MFINDBUGS-61) fixes this issue.

Show
Simon Brandhof added a comment - I think that SONAR-749 (and transitively MFINDBUGS-61) fixes this issue.
Hide
Simon Brandhof added a comment -

Issue is fixed. Findbugs plugin is not executed anymore on EAR projects.

Show
Simon Brandhof added a comment - Issue is fixed. Findbugs plugin is not executed anymore on EAR projects.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: