我正在尝试在我的Maven 3项目上运行声纳。我使用SonarQube 5.0安装了所有最新的插件(Java 3.0,Findbugs 3.1,Codecheck 2.2)。另外,我正在使用最新的maven-sonar-plugin来启动。
我对声纳很新,所以我不完全确定我是否需要特殊配置来让Sonar扫描工作。我开始时遇到以下错误:
java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/ServletException, method=<init>()V, pc=0
所以我尝试在pom中添加一个排除项以排除所有javax文件,但这似乎没有做任何事情;我仍然收到相同的错误消息。让我更加疑惑的是,这些都是“警告”,然而,声纳构建失败了。
这甚至是Sonar Java插件吗?是否需要独立配置的另一个插件(即:checkstyle或findbugs)?是什么导致构建失败?
我没有包含pom文件,因为实际上没有声纳配置存在,除了以下属性(加上主机,网址,密码等)之外:
<sonar.jdbc.driver>oracle.jdbc.driver.OracleDriver</sonar.jdbc.driver>
<sonar.junit.reportsPath>target/surefire-reports</sonar.junit.reportsPath>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
mvn sonar:sonar
的输出(在mvn clean install之后):
[INFO] [12:22:25.635] Index files
[INFO] [12:22:25.647] Excluded sources:
[INFO] [12:22:25.647] **/generated-sources/**
[INFO] [12:22:25.647] **/angular*.js
[INFO] [12:22:25.647] **/jquery*.js
[INFO] [12:22:25.647] **/bootstrap*.js
[INFO] [12:22:25.648] **/underscore*.js
[INFO] [12:22:25.648] **/json3*.js
[INFO] [12:22:25.648] **/modernizr*.js
[INFO] [12:22:25.648] **/es5-shim*.js
[INFO] [12:22:25.648] **/dataTables*.js
[INFO] [12:22:25.648] **/javax/**/*
[INFO] [12:22:31.023] 1782 files indexed
[INFO] [12:22:51.367] Quality profile for java: Sonar way with Findbugs
[INFO] [12:22:51.967] Sensor JavaSquidSensor...
[INFO] [12:22:52.947] Java Main Files AST scan...
[INFO] [12:22:52.969] 1782 source files to be analyzed
[INFO] [12:23:02.970] 41/1782 files analyzed, current is C:\dev\Eclipse\workspace_proj_v6.0\bbi_java\sources\com\me\bbi\admin\agent\dao\User.java
....
[INFO] [12:25:05.046] 1782/1782 source files analyzed
[INFO] [12:25:05.177] Java bytecode scan...
[INFO] [12:25:06.926] Java bytecode scan done: 1749 ms
[INFO] [12:25:06.926] Java Test Files AST scan...
[INFO] [12:25:06.926] 0 source files to be analyzed
[INFO] [12:25:06.927] Java Test Files AST scan done: 1 ms
[INFO] [12:25:06.931] Package design analysis...
[INFO] [12:25:06.951] 0/0 source files analyzed
[INFO] [12:25:17.738] Package design analysis done: 10807 ms
[INFO] [12:25:18.456] Sensor JavaSquidSensor done: 146489 ms
[INFO] [12:25:18.461] Sensor QProfileSensor...
[INFO] [12:25:18.463] Sensor QProfileSensor done: 2 ms
[INFO] [12:25:18.464] Sensor Maven dependencies...
[INFO] [12:25:19.185] Sensor Maven dependencies done: 721 ms
[INFO] [12:25:19.188] Sensor FindbugsSensor...
[INFO] [12:25:19.234] Execute Findbugs 3.0.0...
[INFO] [12:25:20.899] Findbugs output report: C:\dev\Eclipse\workspace_proj_v6.0\bbi_java\target\sonar\findbugs-result.xml
[INFO] [12:27:09.117] Execute Findbugs 3.0.0 done: 109883 ms
[INFO] [12:27:09.224] Sensor FindbugsSensor done: 110036 ms
[INFO] [12:27:09.224] Sensor CheckstyleSensor...
[INFO] [12:27:09.225] Execute Checkstyle 6.1...
[INFO] [12:27:09.238] Checkstyle configuration: C:\dev\Eclipse\workspace_proj_v6.0\bbi_java\target\sonar\checkstyle.xml
java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/ServletException, method=<init>()V, pc=0
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:306)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:711)
at java.net.URLClassLoader.access$400(URLClassLoader.java:92)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1159)
at java.security.AccessController.doPrivileged(AccessController.java:366)
at java.net.URLClassLoader.findClass(URLClassLoader.java:594)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:760)
at java.lang.ClassLoader.loadClass(ClassLoader.java:728)
at java.lang.ClassLoader.loadClass(ClassLoader.java:707)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.puppycrawl.tools.checkstyle.checks.ClassResolver.safeLoad(ClassResolver.java:153)
...
... above warning repeated 50+ times
...
[WARN] [12:27:19.995] C:\dev\Eclipse\workspace_proj_v6.0\bbi_java\sources\com\me\bbi\banking\electronicstatement\ElectronicStatementPDFServlet.java: Got an exception - java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/ServletException, method=<init>()V, pc=0
java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/ServletException, method=<init>()V, pc=0
[WARN] [12:28:08.951] C:\dev\Eclipse\workspace_proj_v6.0\bbi_java\sources\com\me\bbi\wealthmanagement\EntryPointServlet.java: Got an exception - java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/ServletException, method=<init>()V, pc=0
[INFO] [12:28:10.725] Execute Checkstyle 6.1 done: 61500 ms
[INFO] [12:28:10.725] Sensor CheckstyleSensor done: 61501 ms
[INFO] [12:28:10.725] Sensor PmdSensor...
[INFO] [12:28:10.726] Execute PMD 5.2.1...
[INFO] [12:28:10.738] Java version: 1.7
[INFO] [12:28:10.838] PMD configuration: C:\dev\Eclipse\workspace_proj_v6.0\bbi_java\target\sonar\pmd.xml
Mar 19, 2015 12:28:14 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver visit
WARNING: Could not find class com.me.bbi.admin.agent.AgentAdminController, due to: java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/GenericServlet, method=<init>()V, pc=0
Mar 19, 2015 12:28:14 PM net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver visit
WARNING: Could not find class com.bnc.bvi.admin.agent.AgentStartupController, due to: java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified; class=javax/servlet/GenericServlet, method=<init>()V, pc=0
...
... above warning lines repeated several times (50+) for multiple files
...
[INFO] [12:28:23.757] Execute PMD 5.2.1 done: 13031 ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:09 min
[INFO] Finished at: 2015-03-19T12:28:23-04:00
[INFO] Final Memory: 41M/470M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project bbi2: JVMCFRE074 no Code attribute specified; class=javax/servlet/jsp/PageContext, method=<init>()V, pc=0 -> [Help 1]
答案 0 :(得分:0)
这看起来像是Checkstyle和PMD插件的问题。
您可以在其他问题的评论中尝试解决方案(将Java Web依赖关系的范围从compile
更改为provided
:java.lang.ClassFormatError: JVMCFRE074 no Code attribute specified;class=javax/faces/webapp/FacesServlet, method=<init>()V, pc=0