sonarqube代码分析平台踩坑指南

环境描述

系统:win10
版本:sonarqube8.8.0.4
启动StartSonar.bat出现如下错误

错误信息1

--> Wrapper Started as Console
Launching a JVM...
Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.


WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11 to run
java.lang.IllegalStateException: SonarQube requires Java 11 to run
	at com.google.common.base.Preconditions.checkState(Preconditions.java:508)
	at org.sonar.application.App.checkJavaVersion(App.java:93)
	at org.sonar.application.App.start(App.java:56)
	at org.sonar.application.App.main(App.java:97)
	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.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
	at java.lang.Thread.run(Thread.java:748)
<-- Wrapper Stopped

原因分析

需要安装java11版本才能运行,而我只安装了java8

错误信息2

Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
  Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.

2021.04.27 12:36:21 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory D:\sonarqube-8.8.0.42792\temp
2021.04.27 12:36:21 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:59370]
2021.04.27 12:36:21 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [D:\sonarqube-8.8.0.42792\elasticsearch]: C:\Program Files\Java\jdk-16.0.1\bin\java -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Djava.io.tmpdir=D:\sonarqube-8.8.0.42792\temp -XX:ErrorFile=../logs/es_hs_err_pid%p.log -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.locale.providers=COMPAT -Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=D:\sonarqube-8.8.0.42792\elasticsearch -Des.path.conf=D:\sonarqube-8.8.0.42792\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
Unrecognized VM option 'UseConcMarkSweepGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
2021.04.27 12:36:21 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1
2021.04.27 12:36:21 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2021.04.27 12:36:21 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
2021.04.27 12:36:21 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
<-- Wrapper Stopped
--> Wrapper Started as Console

原因分析

SonarQube扫描程序需要JVM的版本8或11,而SonarQube服务器需要的版本11。官方不支持Java 11以外的版本。我这里安装最新版本16导致此问题

解决办法

安装java11版本,记得配置环境变量哦
sonarqube代码分析平台踩坑指南
问题完美解决,脑抽自以为是向上兼容的
sonarqube代码分析平台踩坑指南
访问127.0.0.1:9000 登陆用户:admin 密码:admin
sonarqube代码分析平台踩坑指南

上一篇:sonarqube+sonar-scanner+jenkins安装配置及使用


下一篇:「SonarQube」- 备份与恢复 @20210424