Cannot finish Sonarqube Dev. Edition setup - java.lang.IllegalStateException: Failed to create table schema_migrations

Hello,

I followed the official docs but still have a problem with connecting sonarqube to postgresql database.
I have created the user, database and the schema in it and granted full permissiions to user altogether with ALTER USER mySonarUser SET search_path to mySonarQubeSchema.

Everything is set up as it should be:

sonar.jdbc.username=sonarqube

sonar.jdbc.password=xxxxxxxxx

sonar.jdbc.url=jdbc:postgresql://localhost/sonarqubedb?currentSchema=sonarqube_schema

sonar.web.host=0.0.0.0

sonar.web.context=/sonarqube

sonar.web.port=9000

sonar.path.data=/var/sonarqube/data

sonar.path.temp=/var/sonarqube/temp

Postgre db user sonarqube

Postgre db name: sonarqubedb

Postgre db schema in sonarqubedb database – sonarqube_schema

I already have a valid config for LDAP login and HTTPS redirection, but need to start sonarqube with postgre first.

The web.log excerpt:

94473 2021.08.09 18:00:21 INFO  web[][o.s.s.p.LogServerVersion] SonarQube Server / 9.0.1.46107 / d32acdb9a65112f50702ab8f09521c7ebe80ead0
94474 2021.08.09 18:00:21 INFO  web[][o.sonar.db.Database] Create JDBC data source for jdbc:postgresql://localhost/sonarqubedb?currentSchema=sonarqube_schema
94475 2021.08.09 18:00:21 DEBUG web[][o.postgresql.Driver] Loading driver configuration via classloader jdk.internal.loader.ClassLoaders$AppClassLoader@55054057
94476 2021.08.09 18:00:21 DEBUG web[][o.postgresql.Driver] Connecting with URL: jdbc:postgresql://localhost/sonarqubedb?currentSchema=sonarqube_schema
94477 2021.08.09 18:00:21 DEBUG web[][o.p.c.v.ConnectionFactoryImpl] Trying to establish a protocol version 3 connection to localhost:5432
94478 2021.08.09 18:00:21 DEBUG web[][o.p.c.v.ConnectionFactoryImpl] Receive Buffer Size is 530,648
94479 2021.08.09 18:00:21 DEBUG web[][o.p.c.v.ConnectionFactoryImpl] Send Buffer Size is 1,313,280
94480 2021.08.09 18:00:21 DEBUG web[][o.postgresql.Driver] Connecting with URL: jdbc:postgresql://localhost/sonarqubedb?currentSchema=sonarqube_schema
94481 2021.08.09 18:00:21 DEBUG web[][o.p.c.v.ConnectionFactoryImpl] Trying to establish a protocol version 3 connection to localhost:5432
94482 2021.08.09 18:00:21 DEBUG web[][o.p.c.v.ConnectionFactoryImpl] Receive Buffer Size is 530,648
94483 2021.08.09 18:00:21 DEBUG web[][o.p.c.v.ConnectionFactoryImpl] Send Buffer Size is 1,313,280
94484 2021.08.09 18:00:22 INFO  web[][o.s.s.p.ServerFileSystemImpl] SonarQube home: /opt/sonarqube
94485 2021.08.09 18:00:22 INFO  web[][o.s.s.u.SystemPasscodeImpl] System authentication by passcode is disabled
94486 2021.08.09 18:00:22 INFO  web[][o.s.s.p.d.m.h.MigrationHistoryTableImpl] Creating table schema_migrations
94487 2021.08.09 18:00:22 ERROR web[][o.s.s.p.PlatformImpl] Web server startup failed
94488 java.lang.IllegalStateException: Failed to create table schema_migrations
94489         at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.start(MigrationHistoryTableImpl.java:48)
94490         at java.base/java.util.Optional.ifPresent(Optional.java:183)
94491         at org.sonar.server.platform.platformlevel.PlatformLevel2.start(PlatformLevel2.java:105)
94492         at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:213)
94493         at org.sonar.server.platform.PlatformImpl.startLevel2Container(PlatformImpl.java:179)
94494         at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:87)
94495         at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43)
94496         at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4763)
94497         at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5232)
94498         at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
94499         at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429)
94500         at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
94501         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
94502         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
94503         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
94504         at java.base/java.lang.Thread.run(Thread.java:829)
94505 Caused by: org.postgresql.util.PSQLException: ERROR: no schema has been selected to create in
94506   Position: 14
94507         at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
94508         at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
94509         at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323)
94510         at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
94511         at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401)
94512         at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:322)
94513         at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:308)
94514         at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:284)
94515         at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:279)
94516         at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
94517         at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
94518         at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.execute(MigrationHistoryTableImpl.java:71)
94519         at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.createTable(MigrationHistoryTableImpl.java:59)
94520         at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.start(MigrationHistoryTableImpl.java:45)
94521         ... 15 common frames omitted
94522 2021.08.09 18:00:22 DEBUG web[][o.a.h.i.n.c.PoolingNHttpClientConnectionManager] Connection manager is shutting down
94523 2021.08.09 18:00:22 DEBUG web[][o.a.h.i.n.c.PoolingNHttpClientConnectionManager] Connection manager shut down
94524 2021.08.09 18:00:22 DEBUG web[][o.s.s.a.TomcatAccessLog] Tomcat is started
94525 2021.08.09 18:00:22 INFO  web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
94526 2021.08.09 18:00:22 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process
94527 2021.08.09 18:00:22 DEBUG web[][o.s.s.a.TomcatAccessLog] Tomcat is stopped

Your help would be highly appreciated.

Hi,

Welcome to the community!

This is likely a problem with your JDBC URL.

I know what you’ve shown includes a schema name, but you might look a little more deeply into this. (Sorry, I don’t know the topic well enough to tell you off-hand what to change.)

 
Ann

Hi @luckyz
In addition to checking the schema with your JDBC URL (which should be fine if you’ve left this parameter unchanged with your migration), you may:

  • Check the permissions granted to your username on this particular schema.
    As per SonarQube documentation, create , update , and delete permissions are needed. In normal operations SonarQube will rarely, if ever, need to create new tables, the create permission may have been lost in your case(?).
  • this should not be related but is worth checking I think. As you are not using the default schema (public), you should also make sure that the search_path is pointing at this sonarqube_schema as well, the ALTER USER request needed for that is also given to you with the same documentation page.

Let us know how it goes.
Best regards
Sylvain

2 Likes

Hello, thanks for the comments.
I solved the problem mostly with these commands:

ALTER USER sonarqube SET search_path to sonarqube_schema;
GRANT ALL ON SCHEMA sonarqubedb TO sonarqube;

3 Likes

That’s great, thanks for the update!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.