SonarQube Docker-compose

Hello. I launched SonarQube in Docker-compose, everything worked, but after the database migration, the following error occurs :

2022.05.26 06:42:41 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
sonarqube_1  | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@5c29bfd-org.sonar.server.es.IndexCreator': Initialization of bean failed; nested exception is java.lang.NullPointerException
sonarqube_1  |  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
sonarqube_1  |  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
sonarqube_1  |  at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
sonarqube_1  |  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
sonarqube_1  |  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
sonarqube_1  |  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
sonarqube_1  |  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
sonarqube_1  |  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
sonarqube_1  |  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
sonarqube_1  |  at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:187)
sonarqube_1  |  at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)
sonarqube_1  |  at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:648)
sonarqube_1  |  at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:196)
sonarqube_1  |  at org.sonar.server.platform.PlatformImpl.startLevel34Containers(PlatformImpl.java:177)
sonarqube_1  |  at org.sonar.server.platform.PlatformImpl$1.lambda$doRun$0(PlatformImpl.java:105)
sonarqube_1  |  at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.runIfNotAborted(PlatformImpl.java:344)
sonarqube_1  |  at org.sonar.server.platform.PlatformImpl$1.doRun(PlatformImpl.java:105)
sonarqube_1  |  at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.run(PlatformImpl.java:328)
sonarqube_1  |  at java.base/java.lang.Thread.run(Thread.java:829)
sonarqube_1  | Caused by: java.lang.NullPointerException: null
sonarqube_1  |  at org.sonar.server.es.metadata.MetadataIndexImpl.getMetadata(MetadataIndexImpl.java:98)
sonarqube_1  |  at org.sonar.server.es.metadata.MetadataIndexImpl.getDbVendor(MetadataIndexImpl.java:85)
sonarqube_1  |  at org.sonar.server.es.metadata.EsDbCompatibilityImpl.hasSameDbVendor(EsDbCompatibilityImpl.java:37)
sonarqube_1  |  at org.sonar.server.es.IndexCreator.checkDbCompatibility(IndexCreator.java:204)
sonarqube_1  |  at org.sonar.server.es.IndexCreator.start(IndexCreator.java:94)
sonarqube_1  |  at org.sonar.core.platform.StartableBeanPostProcessor.postProcessBeforeInitialization(StartableBeanPostProcessor.java:33)
sonarqube_1  |  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
sonarqube_1  |  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
sonarqube_1  |  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
sonarqube_1  |  ... 18 common frames omitted
sonarqube_1  | 2022.05.26 06:42:42 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process
sonarqube_1  | 2022.05.26 06:42:42 INFO  app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
sonarqube_1  | 2022.05.26 06:42:43 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 143
sonarqube_1  | 2022.05.26 06:42:43 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
sonarqube_1  | 2022.05.26 06:42:43 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped

My Dockerfile - sonarqube:9.4.0-ntk:

FROM alpine:3.14.3

ENV LANG='en_US.UTF-8' \
    LANGUAGE='en_US:en' \
    LC_ALL='en_US.UTF-8'

#
# SonarQube setup
#
ARG SONARQUBE_VERSION=9.4.0.54424
ARG SONARQUBE_ZIP_URL=https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-${SONARQUBE_VERSION}.zip
ENV JAVA_HOME='/usr/lib/jvm/java-11-openjdk' \
    PATH="/opt/java/openjdk/bin:$PATH" \
    SONARQUBE_HOME=/opt/sonarqube \
    SONAR_VERSION="${SONARQUBE_VERSION}" \
    SQ_DATA_DIR="/opt/sonarqube/data" \
    SQ_EXTENSIONS_DIR="/opt/sonarqube/extensions" \
    SQ_LOGS_DIR="/opt/sonarqube/logs" \
    SQ_TEMP_DIR="/opt/sonarqube/temp"

RUN set -eux; \
    addgroup -S -g 1000 sonarqube; \
    adduser -S -D -u 1000 -G sonarqube sonarqube; \
    apk add --no-cache --virtual build-dependencies gnupg unzip curl; \
    apk add --no-cache bash su-exec ttf-dejavu openjdk11-jre; \
    # pub   2048R/D26468DE 2015-05-25
    #       Key fingerprint = F118 2E81 C792 9289 21DB  CAB4 CFCA 4A29 D264 68DE
    # uid                  sonarsource_deployer (Sonarsource Deployer) <infra@sonarsource.com>
    # sub   2048R/06855C1D 2015-05-25
    echo "networkaddress.cache.ttl=5" >> "${JAVA_HOME}/conf/security/java.security"; \
    sed --in-place --expression="s?securerandom.source=file:/dev/random?securerandom.source=file:/dev/urandom?g" "${JAVA_HOME}/conf/security/java.security"; \
    for server in $(shuf -e hkps://keys.openpgp.org \
                            hkps://keyserver.ubuntu.com) ; do \
        gpg --batch --keyserver "${server}" --recv-keys 679F1EE92B19609DE816FDE81DB198F93525EC1A && break || : ; \
    done; \
    mkdir --parents /opt; \
    cd /opt; \
    curl --fail --location --output sonarqube.zip --silent --show-error "${SONARQUBE_ZIP_URL}"; \
    curl --fail --location --output sonarqube.zip.asc --silent --show-error "${SONARQUBE_ZIP_URL}.asc"; \
    gpg --batch --verify sonarqube.zip.asc sonarqube.zip; \
    unzip -q sonarqube.zip; \
    mv "sonarqube-${SONARQUBE_VERSION}" sonarqube; \
    rm sonarqube.zip*; \
    rm -rf ${SONARQUBE_HOME}/bin/*; \
    chown -R sonarqube:sonarqube ${SONARQUBE_HOME}; \
    # this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
    chmod -R 777 "${SQ_DATA_DIR}" "${SQ_EXTENSIONS_DIR}" "${SQ_LOGS_DIR}" "${SQ_TEMP_DIR}"; \
    apk del --purge build-dependencies;

COPY --chown=sonarqube:sonarqube run.sh sonar.sh ${SONARQUBE_HOME}/bin/

WORKDIR ${SONARQUBE_HOME}
EXPOSE 9000

STOPSIGNAL SIGINT

ENTRYPOINT ["/opt/sonarqube/bin/run.sh"]
CMD ["/opt/sonarqube/bin/sonar.sh"]

My Docker-compose:

version: "3"
services:
  sonarqube:
    image: sonarqube:9.4.0-ntk
    depends_on:
      - db
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonarqube
      SONAR_JDBC_USERNAME: sonar
      SONAR_JDBC_PASSWORD: sonar
    volumes:
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions
      - sonarqube_logs:/opt/sonarqube/logs
    ports:
      - "9000:9000"
  db:
    image: postgres:11
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonar
      POSTGRES_DB: sonarqube
    volumes:
      - postgresql:/var/lib/postgresql
      - postgresql_data:/var/lib/postgresql/data

volumes:
  sonarqube_data:
  sonarqube_extensions:
  sonarqube_logs:
  postgresql:
  postgresql_data:

Hi,

What do your server logs say?

 
Ann

I’m sorry, I’ve already figured it out. It happens to me so often. I ask for help, and in the end I decide for myself)))