FindBugs 不接受 ANT 脚本中的 bcel.jar
我将 findbugs 安装到我的 ant lib 目录中,并将以下代码添加到我的主 ANT 脚本中:
<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>
在 init 目标中调用以下 xml:
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
运行 ANT 脚本时,我得到的只是以下输出:
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
为什么 findbugs 不起作用?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您与旧版本的 BCEL 存在冲突,必须消除该冲突。 它可能位于您的 jre/lib/ext 目录中(坏主意),或者您项目的 CLASSPATH 的一部分,或者可能是 Ant /lib 的一部分。 无论如何,您应该在 CLASSPATH 中找到所有 BCEL JAR,将其删除,然后使用 FindBugs 所需的版本更新它们。
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.
Java 版本 1.6.0_06 包含旧的 BCEL 库。
java版本“1.6.0_06”
Java(TM) SE 运行时环境(版本 1.6.0_06-b02)
Java HotSpot(TM) 客户端虚拟机(版本 10.0-b22,混合模式)
一旦我更改为 1.5.0_17,它对我来说就可以正常工作。
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.
我发现
xalan:xalan:jar:2.6.0
库(这是org.apache.xmlgraphics:batik-bridge:jar:1.7
的传递依赖项)我的项目中的库)包含 org.apache.bcel.generic.ObjectType 类(可能是错误的版本)。 这个类可能会导致以下错误:由于编译不需要该工件(在我们的例子中),我们只是将其范围更改为 Maven
pom.xml 中的
文件,这个错误消失了,runtime
。 xmlmvn clean findbugs:findbugs findbugs:gui
再次工作(至少对我来说):希望这能拯救某人的屁股......
I found out that the
xalan:xalan:jar:2.6.0
library (which was a transitive dependency of theorg.apache.xmlgraphics:batik-bridge:jar:1.7
library in my project) contains theorg.apache.bcel.generic.ObjectType
class (in a wrong version, perhaps). This class is, perhaps, the one which causes the following error:As the artifact was not needed for compilation (in our case), we just changed its scope to
runtime
in the Mavenpom.xml
file and this error disappeared and themvn clean findbugs:findbugs findbugs:gui
works again (at least for me):Hope this saves someone's ass...
如果 findbugs 有自己的 BCEL 版本,那么为什么我会收到此错误:
如果我从 findbugs.home 目录中删除 bcel.jar,则会出现此错误。
If findbugs has its own version of BCEL then why do I get this error:
This error occurs if I remove bcel.jar from the findbugs.home directory.