SonarScanner运行报错:无法连接数据库

LiuMiller 发布于 2017/05/16 18:42
阅读 3K+
收藏 0

@Yashin 你好,想跟你请教个问题:我按照该教程学习Sonar,但是最后一步利用SonarScanner分析工具分析源代码时报错,我在同事电脑按照这个步骤是没有问题的,且我使用的Java环境软件版本均一致,请教一下该问题是什么原因造成的,非常感谢!(该问题已经解决3天了,实在无能为力了)教程链接:http://www.cnblogs.com/qiaoyeye/p/5249786.htmlSonarScanner。

SQL:

DROP DATABASE sonar;

CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE USER 'sonar' IDENTIFIED BY 'sonar';

GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';

GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';

FLUSH PRIVILEGES;

连接的参数均为

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

sonar.jdbc.username=sonar

sonar.jdbc.password=sonar

sonar.sorceEncoding=UTF-8

sonar.login=admin

sonar.password=admin

加载中
0
Yashin
Yashin

黑框是 sonar-scanner 报的错?有提示加 -e 参数查看详细错误堆栈了,有试过吗?详细错误堆栈贴出来看看?下面白框应该是 sonar web的日志吧,最好提问描述清晰一下上下文哦,比如执行了哪个命令报,就丢个链接这样很难有人有时间猜测一下再研究一下再跟你交流的。

Yashin
Yashin
sonar-runner -e 看看详细错误堆栈,如果真是插件无法下载就看看以下目录是否有相应的插件了,没有的话要先下载插件Sonar/extensions/plugins
Yashin
Yashin
并且建议入门一个软件或者技术最好按官方文档来
0
LiuMiller
LiuMiller

目前学习Sonar工具来分析源码。

以下是操作步骤

1.配置数据库,创建一个sonar数据库。

2.启动Sonar服务,通过sonarqube安装目录下的sonar.properties文件初始化数据库(数据库初始化成功)

3.利用SonarScanner工具执行源码分析。需要配置环境变量name=SONAR_RUNNER_HOME。value=D:\sonar\sonar-scanner-2.5,并且在需要分析的项目根目录,创建建sonar-project.properties文件,以上工作全部完成。

4.启动sonarqube服务,并启动cmd,在cmd进入项目所在的根目录,输入命令:sonar-runner

正常是能执行代码分析的,但是此处加载插件时失败。(可以排除各个软件版本的问题)

 

Yashin
Yashin
sonar-runner -e
0
LiuMiller
LiuMiller

C:\Users\Administrator\Desktop\sonar\netctoss>sonar-runner -e
C:\Users\Administrator\Desktop\sonar\sonar-scanner-2.5
INFO: Scanner configuration file: C:\Users\Administrator\Desktop\sonar\sonar-scanner-2.5\conf\sonar-runner.properties
INFO: Project configuration file: C:\Users\Administrator\Desktop\sonar\netctoss\sonar-project.properties
INFO: SonarQube Scanner 2.5
INFO: Java 1.7.0_80 Oracle Corporation (64-bit)
INFO: Windows 8.1 6.3 amd64
INFO: Error stacktraces are turned on.
INFO: User cache: C:\Users\Administrator\.sonar\cache
INFO: Load global repositories
INFO: Load global repositories (done) | time=169ms
INFO: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: User cache: C:\Users\Administrator\.sonar\cache
INFO: Load plugins index
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.195s
INFO: Final Memory: 38M/303M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
org.sonarqube.ws.client.HttpException: Error 500 on http://localhost:9000/deploy/plugins/index.txt
        at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:32)
        at org.sonar.batch.bootstrap.BatchWsClient.failIfUnauthorized(BatchWsClient.java:96)
        at org.sonar.batch.bootstrap.BatchWsClient.call(BatchWsClient.java:67)
        at org.sonar.batch.cache.WSLoader$1.load(WSLoader.java:62)
        at org.sonar.batch.cache.WSLoader$1.load(WSLoader.java:58)
        at org.sonar.batch.cache.WSLoader.loadFromServer(WSLoader.java:225)
        at org.sonar.batch.cache.WSLoader.loadFromServerFirst(WSLoader.java:188)
        at org.sonar.batch.cache.WSLoader.load(WSLoader.java:148)
        at org.sonar.batch.cache.WSLoader.loadString(WSLoader.java:134)
        at org.sonar.batch.cache.WSLoader.loadString(WSLoader.java:129)
        at org.sonar.batch.bootstrap.BatchPluginInstaller.loadPluginIndex(BatchPluginInstaller.java:132)
        at org.sonar.batch.bootstrap.BatchPluginInstaller.listRemotePlugins(BatchPluginInstaller.java:117)
        at org.sonar.batch.bootstrap.BatchPluginInstaller.installRemotes(BatchPluginInstaller.java:72)
        at org.sonar.batch.bootstrap.BatchPluginRepository.start(BatchPluginRepository.java:54)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
        at org.sonar.core.platform.ComponentContainer$1.start(ComponentContainer.java:291)
        at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
        at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
        at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
        at org.picocontainer.behaviors.Stored.start(Stored.java:110)
        at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
        at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
        at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:131)
        at org.sonar.batch.bootstrapper.Batch.start(Batch.java:103)
        at org.sonar.runner.batch.BatchIsolatedLauncher.start(BatchIsolatedLauncher.java:57)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.sonar.runner.impl.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:61)
        at com.sun.proxy.$Proxy0.start(Unknown Source)
        at org.sonar.runner.api.EmbeddedRunner.doStart(EmbeddedRunner.java:251)
        at org.sonar.runner.api.EmbeddedRunner.start(EmbeddedRunner.java:187)
        at org.sonar.runner.api.EmbeddedRunner.start(EmbeddedRunner.java:182)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:66)
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

0
LiuMiller
LiuMiller

我现在是找到问题所在了,但是为什么造成这样不清楚

0
LiuMiller
LiuMiller

请教加载失败的原因。我把在同事电脑正常加载.sonar是文件夹拷贝到根目录下,依旧是报相同的错误,还是得需要它自己正常加载。

0
Yashin
Yashin

sonar-ruuner 执行分析之前是要从sonar web下载插件,你这种情况应该是下载失败了,建议取你同事的环境拷贝 Sonar/sonarqube-5.3/extensions/plugins 下的插件。然后重启 sonar web。再试试

返回顶部
顶部