Problem migrating Sonar DB from sql express to sql developer

Must-share information (formatted with Markdown):

  • using SonarQube 9.9 developer license

  • deployed with zip

  • I’m trying to migrate the sonar DB from a sql server express edition to sql server developer edition. I tried but couldn’t find any documentation on the Sonar website explaining how to do this.

  • I have the new sql developer edition up and running and restored the sonar DB to it. The sonar windows service stops as soon as I try accessing the web interface.

  • I see these errors in the sonar logs, so it looks like it’s trying to create things that already exist.
    org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #1 ‘Create initial schema’ failed

    Fail to execute CREATE TABLE active_rule_parameters

    There is already an object named ‘active_rule_parameters’ in the database

Here’s the full error:

2025.02.04 12:13:15 ERROR web[][o.s.s.p.PlatformImpl] Web server startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@659e0bfd-org.sonar.server.platform.db.migration.AutoDbMigration': Initialization of bean failed; nested exception is org.sonar.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #1 'Create initial schema' failed
	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:920)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:187)
	at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)
	at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:196)
	at org.sonar.server.platform.PlatformImpl.startSafeModeContainer(PlatformImpl.java:188)
	at org.sonar.server.platform.PlatformImpl.doStart(PlatformImpl.java:90)
	at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:44)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4494)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4946)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	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:871)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:795)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	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:871)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:249)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:917)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486)
	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.server.platform.db.migration.step.MigrationStepExecutionException: Execution of migration step #1 'Create initial schema' failed
	at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:79)
	at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:67)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
	at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:52)
	at org.sonar.server.platform.db.migration.engine.MigrationEngineImpl.execute(MigrationEngineImpl.java:66)
	at org.sonar.server.platform.db.migration.AutoDbMigration.start(AutoDbMigration.java:40)
	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)
	... 43 common frames omitted
Caused by: java.lang.IllegalStateException: Fail to execute CREATE TABLE active_rule_parameters (uuid NVARCHAR (40) NOT NULL,value NVARCHAR (4000) NULL,rules_parameter_key NVARCHAR (128) NULL,active_rule_uuid NVARCHAR (40) NOT NULL,rules_parameter_uuid NVARCHAR (40) NOT NULL, CONSTRAINT pk_active_rule_parameters PRIMARY KEY (uuid))
	at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(DdlChange.java:106)
	at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(DdlChange.java:86)
	at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(DdlChange.java:128)
	at org.sonar.server.platform.db.migration.version.v00.CreateInitialSchema.createActiveRuleParameters(CreateInitialSchema.java:171)
	at org.sonar.server.platform.db.migration.version.v00.CreateInitialSchema.execute(CreateInitialSchema.java:97)
	at org.sonar.server.platform.db.migration.step.DdlChange.execute(DdlChange.java:45)
	at org.sonar.server.platform.db.migration.step.MigrationStepsExecutorImpl.execute(MigrationStepsExecutorImpl.java:75)
	... 52 common frames omitted
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: There is already an object named 'active_rule_parameters' in the database.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1676)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:907)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:802)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7627)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3916)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:268)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:242)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:775)
	at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94)
	at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
	at org.sonar.server.platform.db.migration.step.DdlChange$ContextImpl.execute(DdlChange.java:91)
	... 58 common frames omitted
2025.02.04 12:13:15 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown initiated...
2025.02.04 12:13:15 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown completed.
2025.02.04 12:13:15 INFO  web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2025.02.04 12:13:15 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process

Hey there.

SonarQube typically only tries to start a database from scratch if there is no value in the schema_migrations table indicating what “version” the schema is at.

In your migrated SQL Server Developer Edition database, Does this table include any values (and for that matter, do any other tables)? Sometimes it’s possible for users to only migrate the schema by mistake, not any data.

Every DB Provider (and every DBA for that matter) has their own backup/restore procedures. We leave it to the experts.

Whoah, that is what happened here somehow. All the schema is there, but no data when I try to get anything back from any of the tables. I noticed that the colation was different between the old sql instance and the new one, and that the version of ms sql server is actually a lower version on the new instance. I’m going to have our sql team install the same version of sql, and to make sure the colation is Latin1_General_CS_AS as is required according to the sonar documentation.

Collation must be case-sensitive (CS) and accent-sensitive (AS) (example: Latin1_General_CS_AS ).

Thank you Colin for suggesting to check the tables had data in them!

1 Like

Not sure if it was the collation difference, the sql server version difference, or both, but after reinstalling the same version of sql server with the Latin1_General_CS_AS collation, everything works now. Note that I still went from sql express edition to sql developer edition, but changed the sql server version to match what the express edition instance was (sql server 2017).