Marek Slama
Marek Slama

Reputation: 51

Sonar 5.6.4 and 6.1 fails to install on fresh MS SQL Server 2012

When I start Sonar on fresh (empty) MS SQL Server 2012 DB it runs some migration code which fails. I get error below. I can provide full log if anyone is able to create issue in Sonar JIRA. Could it be problem with locale set on driver side?

    2017.01.17 12:32:40 INFO  web[DbMigration] ==  CreateDefaultUsersAndGroups: migrating ====================================
2017.01.17 12:32:40 INFO  web[jruby.rack] An exception happened during JRuby-Rack startup
An error has occurred, this and all later migrations canceled:

ActiveRecord::JDBCError: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.: INSERT INTO [groups] ([name], [description], [created_at], [updated_at]) VALUES(N'sonar-administrators', N'System administrators', '2017-01-17 12:32:40', '2017-01-17 12:32:40')


2017.01.17 12:32:40 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.RubyRailsContextListener
org.jruby.rack.RackInitializationException: An error has occurred, this and all later migrations canceled:

ActiveRecord::JDBCError: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.: INSERT INTO [groups] ([name], [description], [created_at], [updated_at]) VALUES(N'sonar-administrators', N'System administrators', '2017-01-17 12:32:40', '2017-01-17 12:32:40')
    from /apps/eqbld/eqsonar/sonarqube-5.6.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'
    from /apps/eqbld/eqsonar/sonarqube-5.6.4/web/WEB-INF/gems/gems/activerecord-2.3.15/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
    from /apps/eqbld/eqsonar/sonarqube-5.6.4/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:183:in `execute'
    from /apps/eqbld/eqsonar/sonarqube-5.6.4/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:222:in `insert_sql'
    from /apps/eqbld/eqsonar/sonarqube-5.6.4/web/WEB-INF/gems/gems/activerecord-jdbc-adapter-1.1.3/lib/arjdbc/jdbc/adapter.rb:195:in `jdbc_insert'

According to this SQL Error: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value and my testing using MS SQL Server Management Studio it works when T is inserted between date and time ie this: INSERT INTO [groups] ([name], [description], [created_at], [updated_at]) VALUES(N'sonar-administrators', N'System administrators', '2017-01-17T13:45:01', '2017-01-17T13:45:01');

works fine. Unfortunately I did not find any workaround on my side (any driver or environment setting). So far it looks like it will require fix at Sonar side.

Upvotes: 1

Views: 165

Answers (2)

Thiago Santana
Thiago Santana

Reputation: 51

After doing what Marek Slama said above, restarting Sonar won´t be enough.

I´ve tried that and you will get another error.

You should delete all tables and entries from the schema you are using for Sonar and then restart the service or run Sonar again.

With this, all the database will be created correctly and you should have no problem.

To do the cleaning, I would recommend executing this script: Drop all the tables, stored procedures, triggers, constraints and all the dependencies in one sql statement

Upvotes: 0

Marek Slama
Marek Slama

Reputation: 51

It looks like setting explicit default language for login fixes this issue: ALTER LOGIN [login name] WITH DEFAULT_LANGUAGE=English It would be good to add this to troubleshooting in installation instructions.

Upvotes: 2

Related Questions