Sonarqube will not start due to elasticsearch being unable to write yml settings file?

Trying to evaluate sonarqube 7.9.1 on an ubuntu linux system. Cannot seem to get sonarqube started. Every time I install or fix something, something else breaks. Initially could not run elasticsearch because I was trying to start sonarqube as root. I added sonarqube user but then I got an error about sonarqube not being able to write to elasticsearch yml settings file.

Also, when I try to start sonarqube as an initd service, I get the error about sonarqube unable to run elasticsearch as root again. This is getting a little crazy. How do I ensure the proper user is used by sonarqube as a service to run elasticsearch or whatever else it needs?

Can someone throw me a bone here?

Here is the sonar.log log file excerpt with the errors:

--> 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.

2019.10.18 15:24:13 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/sonarqube-7.9.1/temp
2019.10.18 15:24:13 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
2019.10.18 15:24:13 ERROR app[][o.s.a.p.ManagedProcessHandler] Fail to launch process [es]
java.lang.IllegalStateException: Cannot write Elasticsearch yml settings file
        at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:53)
        at org.sonar.application.ProcessLauncherImpl.writeConfFiles(ProcessLauncherImpl.java:152)
        at org.sonar.application.ProcessLauncherImpl.launch(ProcessLauncherImpl.java:84)
        at org.sonar.application.SchedulerImpl.lambda$tryToStartProcess$2(SchedulerImpl.java:192)
        at org.sonar.application.process.ManagedProcessHandler.start(ManagedProcessHandler.java:72)
        at org.sonar.application.SchedulerImpl.tryToStartProcess(SchedulerImpl.java:190)
        at org.sonar.application.SchedulerImpl.tryToStartEs(SchedulerImpl.java:142)
        at org.sonar.application.SchedulerImpl.tryToStartAll(SchedulerImpl.java:134)
        at org.sonar.application.SchedulerImpl.schedule(SchedulerImpl.java:108)
        at org.sonar.application.App.start(App.java:68)
        at org.sonar.application.App.main(App.java:98)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.nio.file.AccessDeniedException: /opt/sonarqube/sonarqube-7.9.1/temp/conf/es/elasticsearch.yml
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
        at java.base/java.nio.file.Files.newOutputStream(Files.java:219)
        at java.base/java.nio.file.Files.write(Files.java:3422)
        at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:51)
        ... 16 common frames omitted
2019.10.18 15:24:13 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
2019.10.18 15:24:13 INFO  app[][o.s.a.SchedulerImpl] Hard stopping SonarQube
2019.10.18 15:24:13 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped

WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: Cannot write Elasticsearch yml settings file
java.lang.IllegalStateException: Cannot write Elasticsearch yml settings file
        at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:53)
        at org.sonar.application.ProcessLauncherImpl.writeConfFiles(ProcessLauncherImpl.java:152)
        at org.sonar.application.ProcessLauncherImpl.launch(ProcessLauncherImpl.java:84)
        at org.sonar.application.SchedulerImpl.lambda$tryToStartProcess$2(SchedulerImpl.java:192)
        at org.sonar.application.process.ManagedProcessHandler.start(ManagedProcessHandler.java:72)
        at org.sonar.application.SchedulerImpl.tryToStartProcess(SchedulerImpl.java:190)
        at org.sonar.application.SchedulerImpl.tryToStartEs(SchedulerImpl.java:142)
        at org.sonar.application.SchedulerImpl.tryToStartAll(SchedulerImpl.java:134)
        at org.sonar.application.SchedulerImpl.schedule(SchedulerImpl.java:108)
        at org.sonar.application.App.start(App.java:68)
        at org.sonar.application.App.main(App.java:98)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.nio.file.AccessDeniedException: /opt/sonarqube/sonarqube-7.9.1/temp/conf/es/elasticsearch.yml
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:478)
        at java.base/java.nio.file.Files.newOutputStream(Files.java:219)
        at java.base/java.nio.file.Files.write(Files.java:3422)
        at org.sonar.application.es.EsYmlSettings.writeToYmlSettingsFile(EsYmlSettings.java:51)
        ... 16 more
<-- Wrapper Stopped

Ok I got it! I had to delete the conf folder and its files under /opt/sonarqube/sonarqube-7.9.1/temp because they were owned by root (probably from prior execution attempts). I was able to hit the web page and all was looking good until it ran out of memory and stopped. I am guessing I need to configure something. Here’s the log:

sonarqube@default:/opt/sonarqube/sonarqube-7.9.1/bin$ /opt/sonarqube/sonarqube-7.9.1/bin/linux-x86-64/sonar.sh console
Running SonarQube...
wrapper  | --> Wrapper Started as Console
wrapper  | Launching a JVM...
jvm 1    | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1    |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
jvm 1    |
jvm 1    | 2019.10.18 16:36:03 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/sonarqube-7.9.1/temp
jvm 1    | 2019.10.18 16:36:03 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001
jvm 1    | 2019.10.18 16:36:03 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/sonarqube-7.9.1/elasticsearch]: /opt/sonarqube/sonarqube-7.9.1/elasticsearch/bin/elasticsearch
jvm 1    | 2019.10.18 16:36:03 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
jvm 1    | 2019.10.18 16:36:04 INFO  app[][o.e.p.PluginsService] no modules loaded
jvm 1    | 2019.10.18 16:36:04 INFO  app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin]
jvm 1    | OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
jvm 1    | 2019-10-18 16:36:11,646 main ERROR RollingFileManager (/opt/sonarqube/sonarqube-7.9.1/logs/es.log) java.io.FileNotFoundException: /opt/sonarqube/sonarqube-7.9.1/logs/es.log (Permission denied) java.io.FileNotFoundException: /opt/sonarqube/sonarqube-7.9.1/logs/es.log (Permission denied)
jvm 1    |      at java.base/java.io.FileOutputStream.open0(Native Method)
jvm 1    |      at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
jvm 1    |      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
jvm 1    |      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:158)
jvm 1    |      at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:640)
jvm 1    |      at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:608)
jvm 1    |      at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
jvm 1    |      at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
jvm 1    |      at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)
jvm 1    |      at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145)
jvm 1    |      at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61)
jvm 1    |      at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
jvm 1    |      at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
jvm 1    |      at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
jvm 1    |      at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:234)
jvm 1    |      at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:127)
jvm 1    |      at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:302)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
jvm 1    |      at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
jvm 1    |      at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
jvm 1    |      at org.elasticsearch.cli.Command.main(Command.java:90)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93)
jvm 1    |
jvm 1    | 2019-10-18 16:36:11,695 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@2250b9f2] unable to create manager for [/opt/sonarqube/sonarqube-7.9.1/logs/es.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@7e3181aa[pattern=/opt/sonarqube/sonarqube-7.9.1/logs/es.%d{yyyy-MM-dd}.log, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=%d{yyyy.MM.dd HH:mm:ss} %-5level es[][%logger{1.}] %msg%n, filePermissions=null, fileOwner=null]] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@2250b9f2] unable to create manager for [/opt/sonarqube/sonarqube-7.9.1/logs/es.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@7e3181aa[pattern=/opt/sonarqube/sonarqube-7.9.1/logs/es.%d{yyyy-MM-dd}.log, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)]), strategy=DefaultRolloverStrategy(min=-2147483648, max=2147483647, useMax=false), advertiseURI=null, layout=%d{yyyy.MM.dd HH:mm:ss} %-5level es[][%logger{1.}] %msg%n, filePermissions=null, fileOwner=null]]
jvm 1    |      at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115)
jvm 1    |      at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:114)
jvm 1    |      at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)
jvm 1    |      at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:145)
jvm 1    |      at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:61)
jvm 1    |      at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
jvm 1    |      at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
jvm 1    |      at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
jvm 1    |      at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:234)
jvm 1    |      at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:127)
jvm 1    |      at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:302)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
jvm 1    |      at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
jvm 1    |      at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
jvm 1    |      at org.elasticsearch.cli.Command.main(Command.java:90)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93)
jvm 1    |
jvm 1    | 2019-10-18 16:36:11,744 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender
jvm 1    |      at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:235)
jvm 1    |      at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
jvm 1    |      at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
jvm 1    |      at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
jvm 1    |      at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
jvm 1    |      at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:234)
jvm 1    |      at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:127)
jvm 1    |      at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:302)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
jvm 1    |      at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
jvm 1    |      at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
jvm 1    |      at org.elasticsearch.cli.Command.main(Command.java:90)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116)
jvm 1    |      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93)
jvm 1    |
jvm 1    | 2019-10-18 16:36:11,750 main ERROR Null object returned for RollingFile in Appenders.
jvm 1    | 2019-10-18 16:36:11,752 main ERROR Unable to locate appender "file_es" for logger config "root"
jvm 1    | 2019.10.18 16:36:32 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
jvm 1    | 2019.10.18 16:36:32 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='web', ipcIndex=2, logFilenamePrefix=web]] from [/opt/sonarqube/sonarqube-7.9.1]: /usr/lib/jvm/jdk-11.0.5+9/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonarqube/sonarqube-7.9.1/temp --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/common/*:/opt/sonarqube/sonarqube-7.9.1/lib/jdbc/h2/h2-1.3.176.jar org.sonar.server.app.WebServer /opt/sonarqube/sonarqube-7.9.1/temp/sq-process12132849023937701433properties




jvm 1    | 2019.10.18 16:38:45 INFO  app[][o.s.a.SchedulerImpl] Process[web] is up
jvm 1    | 2019.10.18 16:38:46 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[[key='ce', ipcIndex=3, logFilenamePrefix=ce]] from [/opt/sonarqube/sonarqube-7.9.1]: /usr/lib/jvm/jdk-11.0.5+9/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonarqube/sonarqube-7.9.1/temp --add-opens=java.base/java.util=ALL-UNNAMED -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/common/*:/opt/sonarqube/sonarqube-7.9.1/lib/jdbc/h2/h2-1.3.176.jar org.sonar.ce.app.CeServer /opt/sonarqube/sonarqube-7.9.1/temp/sq-process12976905642308675335properties
jvm 1    | OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e0000000, 44695552, 0) failed; error='Not enough space' (errno=12)
jvm 1    | #
jvm 1    | # There is insufficient memory for the Java Runtime Environment to continue.
jvm 1    | # Native memory allocation (mmap) failed to map 44695552 bytes for committing reserved memory.
jvm 1    | # An error report file with more information is saved as:
jvm 1    | # /opt/sonarqube/sonarqube-7.9.1/hs_err_pid1097.log
jvm 1    | 2019.10.18 16:39:23 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ce]: 1
jvm 1    | 2019.10.18 16:39:24 INFO  app[][o.s.a.SchedulerImpl] Process[ce] is stopped
jvm 1    | 2019.10.18 16:39:57 INFO  app[][o.s.a.SchedulerImpl] Process[web] is stopped
jvm 1    | 2019.10.18 16:39:57 INFO  app[][o.s.a.SchedulerImpl] Process[es] is stopped
jvm 1    | 2019.10.18 16:39:57 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
jvm 1    | 2019.10.18 16:39:57 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 143
wrapper  | <-- Wrapper Stopped

Hi,

It looks like your logs are still owned by root. I’d just do a recursive chown if I were you.

 
HTH,
Ann

Thank you. The reason es.log is owned by root is because I have been trying to get sonarqube to run as a service under initd. The problem is that is runs sonarqube as root. Not sure how to change that.

If I remove es.log and start sonarqube interactively like this “./sonar.sh start” or “./sonar.sh console” it starts up and runs but then when I run firefox and request “http://localhost:9000” it says it is starting and then fails because the jvm runs out of memory.

Two problems here that need solutions.

Ok I think I finally got sonarqube to start under init.d. Your guide about configuring as a service is missing a lot.

Basically had to change the process startup command in the init.d shell script at /etc/init.d/sonar (symbolic link) that was provided on the guide here

https://docs.sonarqube.org/latest/setup/operate-server/

so that it runs as sonarqube user and not root, had to ensure all old root owned logs were deleted and finally had to chown of the symbolic link used by init.d.

I had to change this in etc/init.d/sonar:

/usr/bin/sonar $*

to this:

sudo -u sonarqube /usr/bin/sonar $*

I also changed the owner of the sonar symbolic link but had to use a different option to change the link and not the link target, like this:

sudo chown -h sonarqube /etc/init.d/sonar

Note that for Ubuntu the service registration uses a different command than chkconfig called sysv-rc-conf to install the service:

sysv-rc-conf sonar on (which is equivalent to “chkconfig sonar enable”).

You should probably update your guide.

Now I’m just fighting the jvm out-of-memory error and then onto pointing sonarqube to a postgresql instance…hmmph…soon I hope. Here’s the out of memory information that I found in /opt/sonarqube/sonarqube-7.9.1/hs_err_pid2665.log (just happened to find this log when not finding anything in the logs folder stating the error):

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 89522176 bytes for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2830), pid=2665, tid=2671
#
# JRE version:  (11.0.5+9) (build )
# Java VM: OpenJDK 64-Bit Server VM (11.0.5+9-201910111809, mixed mode, aot, sharing, tiered, compressed oops, serial gc, linux-amd64)
# Core dump will be written. Default location: /opt/sonarqube/sonarqube-7.9.1/core
#

---------------  S U M M A R Y ------------

Command Line: -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/sonarqube/sonarqube-7.9.1/temp --add-opens=java.base/java.util=ALL-UNNAMED -Xmx5
12m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] org.sonar.ce.app.CeServer /opt/sonarqube/sonarqube-7.9.1/temp/sq-process126
82350297613366166properties

Host: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, 1 cores, 4G, Ubuntu 16.04.5 LTS
Time: Mon Oct 21 14:09:35 2019 UTC elapsed time: 0 seconds (0d 0h 0m 0s)

Any thoughts on this error?

James

Hi James,

It’s not clear to me from the error you’ve provided which process is shutting down. But since this error is outside the server logs, I’m wondering if your OS “helpfully” shut down the process because it was seen as grabbing too much memory. We have seen this a few times in the past.

If that’s not the case, and the shutdown was caused by an OOM within SonarQube, you’ll need to figure out which of the three processes it happened in. The server logs should help you diagnose that. Then you can increase the appropriate memory allocation (sonar.[process].javaOpts) in $SONARQUBE-HOME/conf/sonar.properties.

 
HTH,
Ann

So if I do get this going where do I put the license key?

Ok I got this running finally. The license key is entered into the web application through the browser.

I should probably create a new topic here but I unzipped the SonarScanner and tried to run against some source code and it ran through a lot but stopeed with an error and said to run with -X option like this:

sonar-scanner -Dsonar.projectKey=SG -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000 -Dsonar.login=XXXXXX561c47934f2887cab469f2XXXXXXXXXX -X

Ran again and got this:

22:53:40.113 INFO: Quality profile for py: Sonar way
22:53:40.114 INFO: Quality profile for web: Sonar way
22:53:40.114 INFO: Quality profile for xml: Sonar way
22:53:40.114 INFO: ------------- Run sensors on module SG
22:53:40.274 INFO: Load metrics repository
22:53:40.329 DEBUG: GET 200 http://localhost:9000/api/metrics/search?f=name,description,direction,qualitative,custom&ps=500&p=1 | time=54ms
22:53:40.345 INFO: Load metrics repository (done) | time=71ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/home/sonarqube/.sonar/cache/a89f1943fc75b65becd9fb4ecab8d913/sonar-tsql-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
22:53:42.955 DEBUG: 'Import external issues report' skipped because one of the required properties is missing
22:53:42.957 DEBUG: 'Import of stylelint issues' skipped because one of the required properties is missing
22:53:42.975 DEBUG: 'Scala Sensor' skipped because there is no related file in current project
22:53:42.983 DEBUG: 'Scoverage sensor for Scala coverage' skipped because one of the required properties is missing
22:53:42.986 DEBUG: 'Import of Scalastyle issues' skipped because there is no related file in current project
22:53:42.990 DEBUG: 'Import of Scapegoat issues' skipped because there is no related file in current project
22:53:43.000 DEBUG: 'Import of Checkstyle issues' skipped because one of the required properties is missing
22:53:43.001 DEBUG: 'Import of PMD issues' skipped because one of the required properties is missing
22:53:43.016 DEBUG: 'Import of SpotBugs issues' skipped because one of the required properties is missing
22:53:43.030 DEBUG: 'Flex' skipped because there is no related file in current project
22:53:43.033 DEBUG: 'Flex Cobertura' skipped because there is no related file in current project
22:53:43.037 DEBUG: 'SonarTS' skipped because there is no related file in current project
22:53:43.041 DEBUG: 'SonarTS Coverage' skipped because there is no related file in current project
22:53:43.043 DEBUG: 'Import of TSLint issues' skipped because one of the required properties is missing
22:53:43.046 DEBUG: 'VB.NET Properties' skipped because there is no related file in current project
22:53:43.048 DEBUG: 'SonarSwift' skipped because there is no related file in current project
22:53:43.054 DEBUG: 'Import of SwiftLint issues' skipped because there is no related file in current project
22:53:43.055 DEBUG: 'gcov' skipped because one of the required properties is missing
22:53:43.056 DEBUG: 'llvm-cov' skipped because one of the required properties is missing
22:53:43.056 DEBUG: 'cppunit' skipped because one of the required properties is missing
22:53:43.057 DEBUG: 'VisualStudioCoverage' skipped because one of the required properties is missing
22:53:43.060 DEBUG: 'bullseye' skipped because one of the required properties is missing
22:53:43.060 DEBUG: 'PylintSensor' skipped because there is no related rule activated in the quality profile
22:53:43.060 DEBUG: 'PylintImportSensor' skipped because there is no related rule activated in the quality profile
22:53:43.067 DEBUG: 'Import of Bandit issues' skipped because one of the required properties is missing
22:53:43.068 DEBUG: 'Go Unit Test Report' skipped because one of the required properties is missing
22:53:43.069 DEBUG: 'Import of go vet issues' skipped because one of the required properties is missing
22:53:43.070 DEBUG: 'Import of Golint issues' skipped because one of the required properties is missing
22:53:43.070 DEBUG: 'Import of GoMetaLinter issues' skipped because one of the required properties is missing
22:53:43.071 DEBUG: 'Kotlin Sensor' skipped because there is no related file in current project
22:53:43.073 DEBUG: 'Import of detekt issues' skipped because there is no related file in current project
22:53:43.080 DEBUG: 'Import of Android Lint issues' skipped because one of the required properties is missing
22:53:43.081 DEBUG: 'T-SQL Sensor' skipped because there is no related file in current project
22:53:43.083 DEBUG: 'SonarJS Coverage' skipped because one of the required properties is missing
22:53:43.083 DEBUG: 'Import of ESLint issues' skipped because one of the required properties is missing
22:53:43.084 DEBUG: 'Ruby Sensor' skipped because there is no related file in current project
22:53:43.085 DEBUG: 'Import of RuboCop issues' skipped because one of the required properties is missing
22:53:43.085 DEBUG: 'SimpleCov Sensor for Ruby coverage' skipped because there is no related file in current project
22:53:43.088 DEBUG: 'AbapSquidSensor' skipped because there is no related file in current project
22:53:43.093 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
22:53:43.093 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
22:53:43.094 DEBUG: 'C# Tests Coverage Report Import' skipped because one of the required properties is missing
22:53:43.095 DEBUG: '[Deprecated] C# Integration Tests Coverage Report Import' skipped because one of the required properties is missing
22:53:43.095 DEBUG: 'C# Unit Test Results Import' skipped because one of the required properties is missing
22:53:43.097 DEBUG: 'VB.NET' skipped because there is no related file in current project
22:53:43.099 DEBUG: 'VB.NET Tests Coverage Report Import' skipped because there is no related file in current project
22:53:43.100 DEBUG: '[Deprecated] VB.NET Integration Tests Coverage Report Import' skipped because there is no related file in current project
22:53:43.101 DEBUG: 'VB.NET Unit Test Results Import' skipped because there is no related file in current project
22:53:43.102 DEBUG: Sensors : JavaSquidSensor -> SonarCSS Metrics -> SonarCSS Rules -> PL/SQL Sensor -> C# Properties -> SurefireSensor -> JaCoCoSensor -> JavaXmlSensor -> HTML -> XML Sensor -> Python Squid Sensor -> Cobertura Sensor for Python coverage -> PythonXUnitSensor -> JaCoCo XML Report Importer -> SonarGo -> SonarJS -> ESLint-based SonarJS -> PHP sensor -> Analyzer for "php.ini" files -> C# -> CFamily -> JavaSecuritySensor -> CSharpSecuritySensor -> PhpSecuritySensor
22:53:43.103 INFO: Sensor JavaSquidSensor [java]
22:53:43.369 INFO: Configured Java source version (sonar.java.source): none
22:53:43.379 INFO: JavaClasspath initialization
22:53:43.408 INFO: ------------------------------------------------------------------------
22:53:43.408 INFO: EXECUTION FAILURE
22:53:43.408 INFO: ------------------------------------------------------------------------
22:53:43.409 INFO: Total time: 46.070s
22:53:43.469 INFO: Final Memory: 22M/77M
22:53:43.469 INFO: ------------------------------------------------------------------------
22:53:43.469 ERROR: Error during SonarQube Scanner execution
org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
        at org.sonar.java.JavaClasspath.init(JavaClasspath.java:64)
        at org.sonar.java.AbstractJavaClasspath.getElements(AbstractJavaClasspath.java:280)
        at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:209)
        at org.sonar.java.JavaSquid.<init>(JavaSquid.java:84)
        at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:87)
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
        at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        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:189)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
        at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Not sure what to do next.

Hi,

It would have been better to open a new thread, and if you need to go much farther with this, then I ask that you do that. However, this one’s pretty easy. Here’s your error:

Your project includes Java, but you didn’t pass in the location of your .class files to analysis.

 
Ann