2012-10-05 70 views
3

的FindBugs:FindBugs的問題與螞蟻

[findbugs] Executing findbugs from ant task 
[findbugs] Running FindBugs... 
[findbugs] java.lang.NoClassDefFoundError: org/apache/bcel/classfile/ClassFormtException 
[findbugs] Caused by: java.lang.ClassNotFoundException: org.apache.bcel.classfile.ClassFormatException 
[findbugs]  at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
[findbugs]  at java.security.AccessController.doPrivileged(Native Method) 
[findbugs]  at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
[findbugs]  at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
[findbugs]  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
[findbugs]  at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
[findbugs] Could not find the main class: edu.umd.cs.findbugs.FindBugs2. Program will exit. 
[findbugs] Exception in thread "main" 

我得到與螞蟻執行FindBugs的,雖然我一直在所需的文件夾FindBugs的和必要的jar文件這個問題。

我使用findbugs 1.3.2和bcel 5.2。

如何解決這個問題?

[findbugs] Output saved to bugs/reports/findbugs.xml 

回答

3

findbugs documentation狀態如下:

強烈建議您使用Ant任務與它附帶的FindBugs的版本。我們不保證Ant任務Jar文件可以與FindBugs以外的任何版本的FindBugs一起使用。

你不知道你使用Ant任務的版本....

我會建議使用一個依賴管理像ivy如下打理複雜的類路徑:

<project name="demo" default="findbugs" xmlns:ivy="antlib:org.apache.ivy.ant"> 

    <target name="init" description="Use ivy to manage ANT tasks"> 
     <ivy:cachepath pathid="findbugs.path"> 
      <dependency org="com.google.code.findbugs" name="findbugs-ant" rev="2.0.1" conf="default"/> 
     </ivy:cachepath> 

     <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.path"/> 
    </target> 

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

</project> 

最後,還值得考慮使用Sonar。 Sonar ANT任務管理所有findbugs依賴關係,並運行其他工具,如checkstyle和PMD。

+0

非常感謝您的回覆。 Ant版本是我使用的1.7.1。還有什麼要做? – sindhu

+0

@sindhu。請再次閱讀答案。您尚未指定您正在使用的findbugs ANT任務的版本。我引用了findbugs文檔,其中指出findbugs對修訂號碼很敏感,最後我提供了一個使用ivy下載findbugs的所有依賴項的解決方案,它將整齊地解決您前進的問題。 –

+0

@ Mark O'Connor。再次感謝您的迴應 – sindhu