views:

558

answers:

4

I installed findbugs into my ant lib directory and added the following code into my main ANT script:

<target name="findbugs" depends="init">

    <findbugs home="C:\\findbugs\\" output="html outputFile="C:\\findbugs\\out.html" jvmargs="-Xms512M">
        <sourcePath path="${messageaggregator.src}" />
        <class location="${messageaggregator.src}"/>


    </findbugs>
</target>

The following xml is called within the init target:

<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">

On running the ANT script, all I get is the following output:

findbugs:
    [findbugs] Executing findbugs from ant task
    [findbugs] Running FindBugs...
    [findbugs] BCEL class compatability error.
    [findbugs] The version of class org.apache.bcel.generic.ObjectType found was not compatible with
    [findbugs] FindBugs.  Please remove any BCEL libraries that may be interfering. This may happen
    [findbugs] if you have an old version of BCEL or a library that includes an old version of BCEL
    [findbugs] in an "endorsed" directory.
    [findbugs] Output saved to C:\\findbugs\\out.html

Why is findbugs not working?

+1  A: 

You've got a conflict with an older version of BCEL that you have to get rid of. It might be in your jre/lib/ext directory (bad idea), or part of the CLASSPATH that you've got for your project, or maybe part of the Ant /lib. In any case, you should find all the BCEL JARs in your CLASSPATH, remove them, and update them with the version that FindBugs requires.

duffymo
A: 

If findbugs has its own version of BCEL then why do I get this error:

[findbugs] Executing findbugs from ant task
[findbugs] Running FindBugs...
[findbugs] The java class is not found:  org.apache.bcel.classfile.ClassFormatException
[findbugs] Output saved to C:\\findbugs\\out.html

This error occurs if I remove bcel.jar from the findbugs.home directory.

A: 

I have the same problem with class not found. I need to add paths to external jars (jars are placed in different directory than findbug.jar) for findbug inlcuding bcel.jar into its classpath. But even classpath is right, this error is occuring.

A: 

Java Version 1.6.0_06 contain old BCEL library.

java version "1.6.0_06" Java(TM) SE Runtime Environment (build 1.6.0_06-b02) Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode)

Once I change to 1.5.0_17 it works fine for me.

lawardy