Skip to main content

SonarQube–Troubleshooting

After upgrading a SonarQube server at one of my clients, we encountered some issues. In this post I'll walk you through each problem we experienced and how we solved it.

Let’s start!

java.lang.IllegalStateException: Fail to connect to database

Our first exception doesn’t tell that much. So let’s have a look at the logs:

2024.05.10 10:43:33 INFO  web[][o.s.p.ProcessEntryPoint] Starting Web Server

2024.05.10 10:43:33 INFO  web[][o.s.s.a.TomcatHttpConnectorFactory] Starting Tomcat on port 9000

2024.05.10 10:43:35 INFO  web[][o.s.s.p.LogServerVersion] SonarQube Server / 10.5.1.90531 / a69dd88808638ec33015277e236bca319314ce8b

2024.05.10 10:43:35 INFO  web[][o.s.d.DefaultDatabase] Create JDBC data source for jdbc:sqlserver://server:1433;databaseName=Tfs_Sonar;integratedSecurity=true

2024.05.10 10:43:35 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Starting...

2024.05.10 10:43:37 WARN  web[][o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@4e0e2f2a-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database

2024.05.10 10:43:37 ERROR web[][o.s.s.p.w.PlatformServletContextListener] Web server startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@4e0e2f2a-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)

              at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)

              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)

              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)

              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:929)

              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591)

              at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:225)

              at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)

              at org.sonar.server.platform.platformlevel.PlatformLevel1.start(PlatformLevel1.java:164)

              at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:214)

              at org.sonar.server.platform.PlatformImpl.startLevel1Container(PlatformImpl.java:179)

              at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:79)

              at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:45)

              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4462)

              at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4914)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)

              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

              at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

              at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)

              at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)

              at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:794)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)

              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

              at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

              at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)

              at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)

              at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:248)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:925)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.startup.Tomcat.start(Tomcat.java:438)

              at org.sonar.server.app.EmbeddedTomcat.start(EmbeddedTomcat.java:72)

              at org.sonar.server.app.WebServer.start(WebServer.java:55)

              at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:97)

              at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:81)

              at org.sonar.server.app.WebServer.main(WebServer.java:104)

Caused by: java.lang.IllegalStateException: Fail to connect to database

              at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:130)

              at org.sonar.core.platform.StartableBeanPostProcessor.postProcessBeforeInitialization(StartableBeanPostProcessor.java:33)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)

              ... 44 common frames omitted

Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: "encrypt" property is set to "true" and "trustServerCertificate" property is set to "false" but the driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption: Error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. ClientConnectionId:46e4d52a-8f1f-49ce-940b-9c78be1b555c

              at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:584)

              at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:571)

              at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:98)

              at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:80)

              at org.sonar.db.DefaultDatabase.createHikariDataSource(DefaultDatabase.java:159)

              at org.sonar.db.DefaultDatabase.initDataSource(DefaultDatabase.java:148)

              at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:126)

              ... 48 common frames omitted

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: "encrypt" property is set to "true" and "trustServerCertificate" property is set to "false" but the driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption: Error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. ClientConnectionId:46e4d52a-8f1f-49ce-940b-9c78be1b555c

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:4266)

              at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1965)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3792)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:3348)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:3179)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1953)

              at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1263)

              at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:120)

              at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:360)

              at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)

              at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:461)

              at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:550)

              ... 53 common frames omitted

Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

              at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)

              at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378)

              at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)

              at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:316)

              at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:654)

              at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:473)

              at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:369)

              at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)

              at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480)

              at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458)

              at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201)

              at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172)

              at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1510)

              at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1425)

              at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455)

              at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426)

              at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1854)

              ... 63 common frames omitted

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

              at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439)

              at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306)

              at java.base/sun.security.validator.Validator.validate(Validator.java:264)

              at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:242)

              at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:113)

              at com.microsoft.sqlserver.jdbc.HostNameOverrideX509TrustManager.checkServerTrusted(SQLServerTrustManager.java:88)

              at java.base/sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:1441)

              at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:638)

              ... 75 common frames omitted

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

              at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:148)

              at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:129)

              at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)

              at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434)

              ... 82 common frames omitted

2024.05.10 10:43:37 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

The fix

Whoow! That’s a lot of data. The good news it contains exactly the information we need. SonarQube couldn’t start because it tries to connect to the database using SSL but it could not validate the connection.

To fix this problem, we opened to the <sonarqubeHome>/conf/sonar.properties file and update the connectionstring:

Remark: Notice the trustServerCertificate=true part at the end that we added.

java.lang.IllegalStateException: Fail to connect to database (again)

We restarted SonarQube but again it failed. The exception looked the same but when we checked the log file, we find a different problem:

2024.05.10 10:43:37 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

2024.05.10 10:46:46 INFO  web[][o.s.p.ProcessEntryPoint] Starting Web Server

2024.05.10 10:46:47 INFO  web[][o.s.s.a.TomcatHttpConnectorFactory] Starting Tomcat on port 9000

2024.05.10 10:46:48 INFO  web[][o.s.s.p.LogServerVersion] SonarQube Server / 10.5.1.90531 / a69dd88808638ec33015277e236bca319314ce8b

2024.05.10 10:46:48 INFO  web[][o.s.d.DefaultDatabase] Create JDBC data source for jdbc:sqlserver://brusrv193:1433;databaseName=Tfs_Sonar;integratedSecurity=true;trustServerCertificate=true

2024.05.10 10:46:48 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Starting...

2024.05.10 10:46:57 WARN  web[][o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@4e0e2f2a-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database

2024.05.10 10:46:57 ERROR web[][o.s.s.p.w.PlatformServletContextListener] Web server startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@4e0e2f2a-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)

              at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)

              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)

              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)

              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:929)

              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591)

              at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:225)

              at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)

              at org.sonar.server.platform.platformlevel.PlatformLevel1.start(PlatformLevel1.java:164)

              at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:214)

              at org.sonar.server.platform.PlatformImpl.startLevel1Container(PlatformImpl.java:179)

              at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:79)

              at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:45)

              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4462)

              at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4914)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)

              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

              at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

              at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)

              at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)

              at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:794)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)

              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

              at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

              at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)

              at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)

              at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:248)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:925)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.startup.Tomcat.start(Tomcat.java:438)

              at org.sonar.server.app.EmbeddedTomcat.start(EmbeddedTomcat.java:72)

              at org.sonar.server.app.WebServer.start(WebServer.java:55)

              at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:97)

              at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:81)

              at org.sonar.server.app.WebServer.main(WebServer.java:104)

Caused by: java.lang.IllegalStateException: Fail to connect to database

              at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:130)

              at org.sonar.core.platform.StartableBeanPostProcessor.postProcessBeforeInitialization(StartableBeanPostProcessor.java:33)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)

              ... 44 common frames omitted

Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: This driver is not configured for integrated authentication. ClientConnectionId:42701a78-b1a2-4cbf-a116-f7ed8b600479

              at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:584)

              at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:571)

              at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:98)

              at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:80)

              at org.sonar.db.DefaultDatabase.createHikariDataSource(DefaultDatabase.java:159)

              at org.sonar.db.DefaultDatabase.initDataSource(DefaultDatabase.java:148)

              at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:126)

              ... 48 common frames omitted

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:42701a78-b1a2-4cbf-a116-f7ed8b600479

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:4266)

              at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<init>(AuthenticationJNI.java:78)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:5345)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:5334)

              at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7739)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4384)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:3823)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:3348)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:3179)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1953)

              at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1263)

              at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:120)

              at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:360)

              at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)

              at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:461)

              at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:550)

              ... 53 common frames omitted

Caused by: java.lang.UnsatisfiedLinkError: Unable to load authentication DLL mssql-jdbc_auth-12.6.0.x64

              at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<clinit>(AuthenticationJNI.java:67)

              at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:5344)

              ... 66 common frames omitted

2024.05.10 10:46:57 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

The fix

We had configured out database connection string to use integrated security. To make this work with SonarQube an extra DLL is required that should be copied to the JAVA bin folder.

The DLL and further instructions how to install it, can be found here: SonarQube database installation (sonarsource.com).

org.sonar.api.utils.MessageException: The version of SonarQube is too old. Please upgrade to the Long-Term Active version first.

Finally! An exception that immediately points us to the issue. Just for completeness, here are the logs:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@4e0e2f2a-org.sonar.server.platform.DatabaseServerCompatibility': Initialization of bean failed; nested exception is The version of SonarQube is too old. Please upgrade to the Long-Term Active version first.

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)

              at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)

              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)

              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)

              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:929)

              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591)

              at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:225)

              at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)

              at org.sonar.server.platform.platformlevel.PlatformLevel2.start(PlatformLevel2.java:101)

              at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:214)

              at org.sonar.server.platform.PlatformImpl.startLevel2Container(PlatformImpl.java:186)

              at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:80)

              at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:45)

              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4462)

              at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4914)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)

              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

              at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

              at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)

              at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)

              at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:794)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)

              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

              at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

              at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)

              at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)

              at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:248)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:925)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.startup.Tomcat.start(Tomcat.java:438)

              at org.sonar.server.app.EmbeddedTomcat.start(EmbeddedTomcat.java:72)

              at org.sonar.server.app.WebServer.start(WebServer.java:55)

              at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:97)

              at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:81)

              at org.sonar.server.app.WebServer.main(WebServer.java:104)

Caused by: org.sonar.api.utils.MessageException: The version of SonarQube is too old. Please upgrade to the Long-Term Active version first.

2024.05.10 10:55:44 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown initiated...

2024.05.10 10:55:44 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown completed.

2024.05.10 10:55:44 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

The fix

I couldn’t remember what the original SonarQube version was before the upgrade. So I connected to the database and checked the dbo.Properties table:

Version 5.6.6… Whoops, that is a version that is too old to have a direct upgrade path to the latest version.

After some discussion we decided to move forward with a clean install. So we removed the original database and started the installation again. Unfortunately, this didn’t mean we had no issues anymore.

We encountered one more problem…

Initialization of bean failed; nested exception is Database collation must be case-sensitive and accent-sensitive.

You know the drill. Again we first take a look at the logs:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@4e0e2f2a-org.sonar.server.platform.db.CheckDatabaseCharsetAtStartup': Initialization of bean failed; nested exception is Database collation must be case-sensitive and accent-sensitive. It is Latin1_General_CI_AS but should be Latin1_General_CS_AS.

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)

              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)

              at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)

              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)

              at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)

              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)

              at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)

              at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:929)

              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591)

              at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:225)

              at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)

              at org.sonar.server.platform.platformlevel.PlatformLevel2.start(PlatformLevel2.java:101)

              at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:214)

              at org.sonar.server.platform.PlatformImpl.startLevel2Container(PlatformImpl.java:186)

              at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:80)

              at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:45)

              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4462)

              at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4914)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)

              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

              at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

              at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)

              at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)

              at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:794)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1332)

              at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1322)

              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

              at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)

              at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)

              at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866)

              at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:248)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.StandardService.startInternal(StandardService.java:433)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:925)

              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:171)

              at org.apache.catalina.startup.Tomcat.start(Tomcat.java:438)

              at org.sonar.server.app.EmbeddedTomcat.start(EmbeddedTomcat.java:72)

              at org.sonar.server.app.WebServer.start(WebServer.java:55)

              at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:97)

              at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:81)

              at org.sonar.server.app.WebServer.main(WebServer.java:104)

Caused by: org.sonar.api.utils.MessageException: Database collation must be case-sensitive and accent-sensitive. It is Latin1_General_CI_AS but should be Latin1_General_CS_AS.

2024.05.10 11:05:59 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown initiated...

2024.05.10 11:05:59 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown completed.

2024.05.10 11:05:59 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

The fix

The database collation settings used were not compatible with SonarQube. It was Latin1_General_CI_AS but should have been Latin1_General_CS_AS.

To fix it, I executed the following command:

ALTER DATABASE <dbname> COLLATE Latin1_General_CS_AS;

More details can be found here: Set or change the database collation - SQL Server | Microsoft Learn.

After doing that, our SonarQube instance was finally up and running again.

Popular posts from this blog

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.

Kubernetes–Limit your environmental impact

Reducing the carbon footprint and CO2 emission of our (cloud) workloads, is a responsibility of all of us. If you are running a Kubernetes cluster, have a look at Kube-Green . kube-green is a simple Kubernetes operator that automatically shuts down (some of) your pods when you don't need them. A single pod produces about 11 Kg CO2eq per year( here the calculation). Reason enough to give it a try! Installing kube-green in your cluster The easiest way to install the operator in your cluster is through kubectl. We first need to install a cert-manager: kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.5/cert-manager.yaml Remark: Wait a minute before you continue as it can take some time before the cert-manager is up & running inside your cluster. Now we can install the kube-green operator: kubectl apply -f https://github.com/kube-green/kube-green/releases/latest/download/kube-green.yaml Now in the namespace where we want t...

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Col...