我正在使用Invoke Standalone Sonar Analysis
构建步骤从Jenkins(Ant作业,而不是maven)运行Sonar。我收到以下错误:
15:46:46.369 INFO .s.p.s.SquidExecutor - Java AST scan done: 33664 ms
15:46:46.370 INFO .s.p.s.SquidExecutor - Java bytecode scan...
15:46:46.394 DEBUG b.ClassLoaderBuilder - ----- Classpath analyzed by Squid:
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/soap.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/axis_1.4.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/xerces.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/json_simple.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jdom.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/xml-apis.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-fileupload-1.0.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/httpclient-cache-4.1.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/datedFileAppender-1.0.2.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/xmlParserAPIs.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/httpclient-4.1.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/axis_1.2.1.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jbossweb-2.1.7.GA.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-collections-2.1.1.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/nekohtml.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/excalibur-i18n-1.1.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jawc.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jmxremote.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/httpcore-4.1.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/xmlparserv2.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/junit.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-cli-1.0.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/axis-ant_1.2.1.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/rmissl.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/oc4j.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/slf4j-jdk14-1.6.1.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/servlet.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/trove.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-beanutils.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/axiom-api-1.2.7.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-net-1.4.0.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/j2ee.jar
15:46:46.394 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/httpunit.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-collections-2.1.1_LICENSE.txt
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-digester-1.8.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/log4j-1.2.8.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/velocity-1.4.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/wsdl4j.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/.project
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/.classpath
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jettison-1.0.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/xercesImpl.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jmxtools.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/struts.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/eclipselink.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/ehcache-core-2.6.0.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/ojdbc6.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/xmlplsql.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/snmp4j-1.10.1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons_LICENSE.txt
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/axis-ant_1.4.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-validator.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-dbcp.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/axis2-kernel-1.4.1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-discovery.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jgroups.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-services.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jaas.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jboss-common.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/xerces_LICENSE.txt
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jboss-minimal.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/concurrent.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/resolver.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/geronimo-stax-api_1.0_spec-1.0.1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jdbc2_0-stdext.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/saaj.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-logging.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/runtime12.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jboss-system.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-codec-1.4.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jndi.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/translator.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jboss-jmx.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jms.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jakarta-oro.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jboss-serialization.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jsch-0.1.25.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/quartz-1.5.1_LICENSE.txt
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/castor-1.0.1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/quartz-1.5.1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/gnu-regexp-1.0.8.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/slf4j-api-1.6.1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/axis2-json-1.4.1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jmxri.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jglue_8_1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/aqapi.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/log4j-1.2.8_LICENSE.txt
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/quartz-oracle-1.5.1.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-pool.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-digester-1.8_LICENSE.txt
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jta.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/oro-2.0.8.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jaxrpc.jar
15:46:46.395 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-lang.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-dbutils-1.1.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jboss-common-jdbc-wrapper.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/xalan.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/ejb.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/commons-resources.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jboss-cache.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/nls_charset12.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - /export/home/jenkins/jenkins-ci/jobs/**********/workspace/server/third-party-jars/jmxremote_optional.jar
15:46:46.396 DEBUG b.ClassLoaderBuilder - -----
15:46:46.405 DEBUG b.b.JdbcDriverHolder - To prevent a memory leak, the JDBC Driver [oracle.jdbc.OracleDriver] has been forcibly deregistered
15:46:46.424 DEBUG .b.b.TempDirectories - Delete temporary directory: /tmp/sonar-batch782561628528002755212032328414312003
Total time: 1:15.256s
Final Memory: 14M/207M
Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: java.lang.IllegalStateException: Can not create ClassLoader
at org.sonar.runner.Runner.delegateExecution(Runner.java:189)
at org.sonar.runner.Runner.execute(Runner.java:78)
at org.sonar.runner.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Can not create ClassLoader
at org.sonar.java.bytecode.ClassLoaderBuilder.create(ClassLoaderBuilder.java:62)
at org.sonar.java.bytecode.BytecodeScanner.scan(BytecodeScanner.java:49)
at org.sonar.plugins.squid.SquidExecutor.scanBytecode(SquidExecutor.java:183)
at org.sonar.plugins.squid.SquidExecutor.scan(SquidExecutor.java:87)
at org.sonar.plugins.squid.SquidSensor.analyzeMainSources(SquidSensor.java:82)
at org.sonar.plugins.squid.SquidSensor.analyse(SquidSensor.java:65)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:64)
at org.sonar.batch.phases.Phases.execute(Phases.java:93)
at org.sonar.batch.bootstrap.ProjectModule.doStart(ProjectModule.java:139)
at org.sonar.batch.bootstrap.Module.start(Module.java:83)
at org.sonar.batch.bootstrap.BatchModule.analyze(BatchModule.java:131)
at org.sonar.batch.bootstrap.BatchModule.doStart(BatchModule.java:121)
at org.sonar.batch.bootstrap.Module.start(Module.java:83)
at org.sonar.batch.bootstrap.BootstrapModule.doStart(BootstrapModule.java:121)
at org.sonar.batch.bootstrap.Module.start(Module.java:83)
at org.sonar.batch.Batch.execute(Batch.java:104)
at org.sonar.runner.Launcher.executeBatch(Launcher.java:65)
at org.sonar.runner.Launcher.execute(Launcher.java:58)
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.sonar.runner.Runner.delegateExecution(Runner.java:186)
... 2 more
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.jar.JarFile.<init>(JarFile.java:135)
at java.util.jar.JarFile.<init>(JarFile.java:99)
at org.sonar.java.bytecode.loader.JarLoader.<init>(JarLoader.java:46)
at org.sonar.java.bytecode.loader.SquidClassLoader.<init>(SquidClassLoader.java:48)
at org.sonar.java.bytecode.ClassLoaderBuilder.create(ClassLoaderBuilder.java:60)
... 24 more
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILURE
这并没有给我太多关于这个问题的信息,但它似乎与我传给Sonar的第三方罐有libraries
属性。
有什么想法吗?
答案 0 :(得分:1)
构建日志不完整,所以我看不到您正在使用的Sonar服务器和Sonar的哪个版本....
分析Java堆栈跟踪始终是最佳起点。以下消息指出Sonar正在尝试读取无效的zip文件(BTW Jars是zip存档)
Caused by: java.util.zip.ZipException: error in opening zip file
这个消息进一步说明了Sonar在遇到这个问题时所做的事情:
Caused by: java.lang.IllegalStateException: Can not create ClassLoader
最后,exeception消息的开始表明哪行代码引发了异常:
Exception in thread "main" org.sonar.batch.bootstrapper.BootstrapException: java.lang.IllegalStateException: Can not create ClassLoader
at org.sonar.runner.Runner.delegateExecution(Runner.java:189)
这使我们可以深入研究代码:
在我看来,Sonar加载的其中一个文件无效,可能只是从Sonar服务器部分下载(Sonar管理它自己的依赖项)。
此诊断与以下调试消息一致:
15:46:46.405 DEBUG b.b.JdbcDriverHolder - To prevent a memory leak, the JDBC Driver [oracle.jdbc.OracleDriver] has been forcibly deregistered
15:46:46.424 DEBUG .b.b.TempDirectories - Delete temporary directory: /tmp/sonar-batch782561628528002755212032328414312003
我建议遵循建议并删除此临时目录。 我会更进一步下载Sonar通常在本地工作区创建的隐藏的“.sonar”目录,强制Sonar下载所有文件的新副本。
然后尝试新的分析并希望问题不再发生。