FindBugs 不接受 ANT 脚本中的 bcel.jar

发布于 2024-07-15 04:52:38 字数 1150 浏览 12 评论 0原文

我将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

私藏温柔 2024-07-22 04:52:38

您与旧版本的 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.

黄昏下泛黄的笔记 2024-07-22 04:52:38

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.

冧九 2024-07-22 04:52:38

我发现 xalan:xalan:jar:2.6.0 库(这是 org.apache.xmlgraphics:batik-bridge:jar:1.7 的传递依赖项)我的项目中的库)包含 org.apache.bcel.generic.ObjectType 类(可能是错误的版本)。 这个类可能会导致以下错误:

[INFO] File Encoding is UTF-8
BCEL class compatability error.
The version of class org.apache.bcel.generic.ObjectType found was not compatible with
FindBugs.  Please remove any BCEL libraries that may be interfering.  This may happen
if you have an old version of BCEL or a library that includes an old version of BCEL
in an "endorsed" directory.
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Java returned: 1
[INFO] ------------------------------------------------------------------------
[INFO] Trace
: Java returned: 1
        at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:199)
        at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:153)
        at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:149)
        at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64)
        at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:784)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:758)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
        at org.codehaus.mojo.findbugs.FindBugsGui.execute(FindBugsGui.groovy:163)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

由于编译不需要该工件(在我们的例子中),我们只是将其范围更改为 Maven pom.xml 中的 runtime 。 xml 文件,这个错误消失了,mvn clean findbugs:findbugs findbugs:gui 再次工作(至少对我来说):

  ...
  <dependencies>
    <dependency>
      <groupId>org.apache.xmlgraphics</groupId>
      <artifactId>batik-bridge</artifactId>
      <version>1.7</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
  ...

希望这能拯救某人的屁股......

I found out that the xalan:xalan:jar:2.6.0 library (which was a transitive dependency of the org.apache.xmlgraphics:batik-bridge:jar:1.7 library in my project) contains the org.apache.bcel.generic.ObjectType class (in a wrong version, perhaps). This class is, perhaps, the one which causes the following error:

[INFO] File Encoding is UTF-8
BCEL class compatability error.
The version of class org.apache.bcel.generic.ObjectType found was not compatible with
FindBugs.  Please remove any BCEL libraries that may be interfering.  This may happen
if you have an old version of BCEL or a library that includes an old version of BCEL
in an "endorsed" directory.
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Java returned: 1
[INFO] ------------------------------------------------------------------------
[INFO] Trace
: Java returned: 1
        at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:199)
        at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:153)
        at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:149)
        at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64)
        at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:784)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:758)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:170)
        at org.codehaus.mojo.findbugs.FindBugsGui.execute(FindBugsGui.groovy:163)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

As the artifact was not needed for compilation (in our case), we just changed its scope to runtime in the Maven pom.xml file and this error disappeared and the mvn clean findbugs:findbugs findbugs:gui works again (at least for me):

  ...
  <dependencies>
    <dependency>
      <groupId>org.apache.xmlgraphics</groupId>
      <artifactId>batik-bridge</artifactId>
      <version>1.7</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
  ...

Hope this saves someone's ass...

永不分离 2024-07-22 04:52:38

如果 findbugs 有自己的 BCEL 版本,那么为什么我会收到此错误:

[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

如果我从 findbugs.home 目录中删除 bcel.jar,则会出现此错误。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文