使用java.lang.IllegalStateException错误,Jenkins中的SonarQube扫描程序执行失败

时间:2017-10-10 03:54:55

标签: jenkins sonarqube sonarqube-scan

我们的声纳构建环境详情如下:

  • SonarQube服务器版本 - 5.6.6(64位)。
  • 声纳扫描仪版本 - 3.0.3.778(通过Jenkins中的“执行SonarQube扫描仪”)
  • 声纳-java的插件-4.14.0.11784.jar
  • 声纳的FindBugs-插件-3.6.0.jar
  • 声纳构建机操作系统 - Ubuntu-16.04 LTS-(64位)。
  • 构建模式:Jenkins - (版本2.46.2-LTS)
  • 构建类型:Maven

问题描述:

Jenkins本身声明的(sonar-project.properties)。分析它时失败,但有以下错误。

ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Unable to load component class org.sonar.api.config.Settings
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:69)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
    at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:272)
    at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:112)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:140)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.batch.repository.ProjectRepositories
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:69)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
    at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
    at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
    at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
    at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
    at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67)
    ... 23 more
Caused by: org.sonarqube.ws.client.HttpException: Error 500 on http://100.101.102.103:9000/batch/project.protobuf?key=scm.sesi.sm.ds
    at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:34)
    at org.sonar.batch.bootstrap.BatchWsClient.failIfUnauthorized(BatchWsClient.java:99)
    at org.sonar.batch.bootstrap.BatchWsClient.call(BatchWsClient.java:69)
    at org.sonar.batch.repository.DefaultProjectRepositoriesLoader.load(DefaultProjectRepositoriesLoader.java:58)
    at org.sonar.batch.repository.ProjectRepositoriesProvider.provide(ProjectRepositoriesProvider.java:39)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
    at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
    at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
    at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
    at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
    at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
    at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
    at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67)
    ... 37 more
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
ERROR: SonarQube scanner exited with non-zero code: 1

sonar.log文件错误如下

2017.10.11 05:03:13 ERROR web[o.s.s.w.WebServiceEngine] Fail to process request http://100.101.102.103:9000/batch/project.protobuf?key=scm.sesi.sm.ds
java.lang.NullPointerException: null
    at com.google.protobuf.ByteString.copyFromUtf8(ByteString.java:321) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat.escapeText(TextFormat.java:1892) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.printFieldValue(TextFormat.java:428) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.printSingleField(TextFormat.java:368) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.printField(TextFormat.java:327) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.print(TextFormat.java:314) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.printFieldValue(TextFormat.java:450) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.printSingleField(TextFormat.java:368) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.printField(TextFormat.java:324) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.print(TextFormat.java:314) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat$Printer.access$400(TextFormat.java:288) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at com.google.protobuf.TextFormat.shortDebugString(TextFormat.java:113) ~[protobuf-java-3.0.0-beta-2.jar:na]
    at org.sonarqube.ws.MessageFormatter.print(MessageFormatter.java:32) ~[sonar-ws-5.6.6.jar:na]
    at org.sonar.server.ws.WsUtils.writeProtobuf(WsUtils.java:63) ~[sonar-server-5.6.6.jar:na]
    at org.sonar.server.batch.ProjectAction.handle(ProjectAction.java:83) ~[sonar-server-5.6.6.jar:na]
    at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:107) ~[sonar-server-5.6.6.jar:na]
    at sun.reflect.GeneratedMethodAccessor206.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_111]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_111]
    at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:425) [jruby-complete-1.7.9.jar:na]
    at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:292) [jruby-complete-1.7.9.jar:na]
    at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:44) [jruby-complete-1.7.9.jar:na]
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:70) [jruby-complete-1.7.9.jar:na]
    at rubyjit.Api::JavaWsController$$index_E9F115BCB78D2E226E3015CDA52C1912485D30D0262463297.__file__(/opt/sonarqube-5.6.6/web/WEB-INF/app/controllers/api/java_ws_controller.rb:34) [jruby-complete-1.7.9.jar:na]

请帮我解决。

2 个答案:

答案 0 :(得分:0)

100.101.102.103真的是SonarQube服务器的IP地址吗?如果是这样,您可能忘记了配置中某处URL中的sonar上下文路径。

应该是这样的:

http://100.101.102.103:9000/sonar

而不是:

http://100.101.102.103:9000/

答案 1 :(得分:-1)

这似乎在6.5版中得到修复。请参阅this问题。或者,您可以删除项目,并且可以毫无问题地重新创建项目。