Pages

Thursday, January 20, 2011

SONAR : Database schema must be updated [version/required=152/170]

My sonar build keeps on failing with this error:


[INFO] PicoLifecycleException: method 'public void org.sonar.jpa.session.AbstractDatabaseConnector.start()', instance 'org.sonar.jpa.session.DriverDatabaseConnector@3f26f816, java.lang.RuntimeException: wrapper
Database schema must be updated [version/required=152/170]. Please browse to your sonar homepage.

Firstly, I thought my jtds version is wrong. So, I downloaded the latest one ( jtds-1.2.5.jar ) and copied that to my Sonar installation folder at this location: C:\sonar\extensions\jdbc-driver\mssql
Then Stopped and started the Sonar..But this did not fix my issue.

Then I could not find anything on the google... Then it came to me that this message may be misleading.. and something else might be wrong.. so I checked my maven projects' POM file.

Then only it occurred to me that I did not specify the version for my sonar-maven-plugin in the POM file. SO, it must be always going for the latest version by default.. which is 2.5 and this 2.5 version of sonar-maven plugin was conflicting (i.e. not compatible) with my installed sonar server (which is at 2.4.1 version). Then, I specified the version number for the sonar-maven-plugin to be 2.4.1 and this fixed my issue.

Error Message that I was getting:

[INFO] ------------------------------------------------------------------------
[INFO] Building Suite Modules Build Project
[INFO]    task-segment: [sonar:sonar] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [sonar:sonar {execution: default-cli}]
[INFO]  Database dialect class org.sonar.jpa.dialect.MsSql
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] PicoLifecycleException: method 'public void org.sonar.jpa.session.AbstractDatabaseConnector.start()', instance 'org.sonar.jpa.session.DriverDatabaseConnector@3f26f816, java.lang.RuntimeException: wrapper
Database schema must be updated [version/required=152/170]. Please browse to your sonar homepage.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.picocontainer.PicoLifecycleException: PicoLifecycleException: method 'public void org.sonar.jpa.session.AbstractDatabaseConnector.start()', instance 'org.sonar.jpa.session.DriverDatabaseConnector@3f26f816, java.lang.RuntimeException: wrapper
    at org.picocontainer.monitors.NullComponentMonitor.lifecycleInvocationFailed(NullComponentMonitor.java:77)
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.monitorAndThrowReflectionLifecycleException(ReflectionLifecycleStrategy.java:132)
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:115)
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
    at org.picocontainer.adapters.InstanceAdapter.start(InstanceAdapter.java:108)
    at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
    at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
    at org.picocontainer.behaviors.Stored.start(Stored.java:110)
    at org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:996)
    at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:989)
    at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:746)
    at org.sonar.batch.Batch.execute(Batch.java:65)
    at org.sonar.maven.SonarMojo.executeBatch(SonarMojo.java:142)
    at org.sonar.maven.SonarMojo.execute(SonarMojo.java:133)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.RuntimeException: wrapper
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.monitorAndThrowReflectionLifecycleException(ReflectionLifecycleStrategy.java:130)
    ... 31 more
Caused by: org.sonar.jpa.session.DatabaseException: Database schema must be updated [version/required=152/170]. Please browse to your sonar homepage.
    at org.sonar.jpa.session.AbstractDatabaseConnector.start(AbstractDatabaseConnector.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
    ... 30 more


Solution to fix this issue

1) Check the version of your installed sonar server. e.g mine is 2.4.1
2) specify this same version number for your sonar-maven-plugin in your projects POM file as shown below:
<build>
      ....................
        <plugins>
            ......................
            .......................           
            <plugin>
                <groupId>org.codehaus.sonar</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>2.4.1</version> <!-- please do not remove this version.. we need this one only.. -->
            </plugin>
       
          .............
        </plugins>

        ....................
</build>

It is a standard behavior of Maven POMs that if we do not specify the version number for the given artifact then maven will try to find the latest version for this artifact. So, in our case, the latest version of sonar-maven-plugin was not compatible with installed version of sonar server. So, I had to specify the version number for the sonar-maven-plugin explicitly.

I hope this helps you. If something is wrong here... and you think of a better solution then please let me know on this blog. Cheers!

Running Bamboo Service as a local user

I was having problems with my bamboo builds failing to read/write the test results on the server. I was getting this error:

org.apache.maven.surefire.booter.SurefireBooterForkException: Error creating properties files for forking; nested exception is java.io.IOException: The system cannot find the path specified
 
When I checked, Bamboo service was using a system login to access the machine instead of the local user that was setup especially for the Bamboo build plans. So, I set up the bamboo service to run as a local user and it fixed the problem. In this blog, I will show the error that I was getting and instructions on how to setup the bamboo service to run as local.

Problem:

When we install the Bamboo on the windows server, and install the bamboo service, it by default uses the system user login to run the service. Therefore we get this error:

------------------------------------------------------------------------------------------------------------------------------

22-Jul-2010 10:55:35 [INFO] Surefire report directory: C:\Users\automake\bamboo-home\xml-data\build-dir\SUITE-SUITE\monowai\trunk\monowai-jar\target\surefire-reports

22-Jul-2010 10:55:35 [INFO] ------------------------------------------------------------------------
22-Jul-2010 10:55:35 [ERROR] BUILD ERROR
22-Jul-2010 10:55:35 [INFO] ------------------------------------------------------------------------
22-Jul-2010 10:55:35 [INFO] Error creating properties files for forking; nested exception is java.io.IOException: The system cannot find the path specified
22-Jul-2010 10:55:35
22-Jul-2010 10:55:35 [INFO] ------------------------------------------------------------------------
22-Jul-2010 10:55:35 [INFO] Trace
22-Jul-2010 10:55:35 org.apache.maven.lifecycle.LifecycleExecutionException: Error creating properties files for forking; nested exception is java.io.IOException: The system cannot find the path specified
22-Jul-2010 10:55:35 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
22-Jul-2010 10:55:35 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
22-Jul-2010 10:55:35 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
22-Jul-2010 10:55:35 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
22-Jul-2010 10:55:35 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
22-Jul-2010 10:55:35 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
22-Jul-2010 10:55:35 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
22-Jul-2010 10:55:35 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
22-Jul-2010 10:55:35 at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
22-Jul-2010 10:55:35 at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
22-Jul-2010 10:55:35 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
22-Jul-2010 10:55:35 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
22-Jul-2010 10:55:35 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
22-Jul-2010 10:55:35 at java.lang.reflect.Method.invoke(Unknown Source)
22-Jul-2010 10:55:35 at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
22-Jul-2010 10:55:35 at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
22-Jul-2010 10:55:35 at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
22-Jul-2010 10:55:35 at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
22-Jul-2010 10:55:35 Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating properties files for forking; nested exception is java.io.IOException: The system cannot find the path specified
22-Jul-2010 10:55:35 at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:541)
22-Jul-2010 10:55:35 at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
22-Jul-2010 10:55:35 at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
22-Jul-2010 10:55:35 ... 17 more
22-Jul-2010 10:55:35 Caused by: org.apache.maven.surefire.booter.SurefireBooterForkException: Error creating properties files for forking; nested exception is java.io.IOException: The system cannot find the path specified
22-Jul-2010 10:55:35 at org.apache.maven.surefire.booter.SurefireBooter.fork(SurefireBooter.java:629)
22-Jul-2010 10:55:35 at org.apache.maven.surefire.booter.SurefireBooter.forkSuites(SurefireBooter.java:479)
22-Jul-2010 10:55:35 at org.apache.maven.surefire.booter.SurefireBooter.runSuitesForkOnce(SurefireBooter.java:379)
22-Jul-2010 10:55:35 at org.apache.maven.surefire.booter.SurefireBooter.run(SurefireBooter.java:245)
22-Jul-2010 10:55:35 at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugin.java:537)
22-Jul-2010 10:55:35 ... 19 more
22-Jul-2010 10:55:35 Caused by: java.io.IOException: The system cannot find the path specified
22-Jul-2010 10:55:35 at java.io.WinNTFileSystem.createFileExclusively(Native Method)
22-Jul-2010 10:55:35 at java.io.File.checkAndCreate(Unknown Source)
22-Jul-2010 10:55:35 at java.io.File.createTempFile(Unknown Source)
22-Jul-2010 10:55:35 at java.io.File.createTempFile(Unknown Source)
22-Jul-2010 10:55:35 at org.apache.maven.surefire.booter.SurefireBooter.writePropertiesFile(SurefireBooter.java:523)
22-Jul-2010 10:55:35 at org.apache.maven.surefire.booter.SurefireBooter.fork(SurefireBooter.java:621)
22-Jul-2010 10:55:35 ... 23 more
22-Jul-2010 10:55:35 [INFO] ------------------------------------------------------------------------


What this means that the user who owns the bamboo process, do not have write permissions to create the "surefire-reports" folder under target directory.
I checked the Bamboo System Information and found out that we are using "SYSTEM" as a user to run the bamboo. This is default user to run windows services. So, changed this user to local user. Then ran the bamboo build and this has fixed the problem.


Solution:




You should run the bamboo service as local user. To change the user from SYSTEM to local user, I went to

Windows Service Manager >> Configuration >> Services >> Bamboo Server.
Right click on the service and select "properties" option. Set the user here..

You can also follow the instructions given on the atlassian support website as shown below:
http://confluence.atlassian.com/display/BAMBOO/Running+Bamboo+service+on+Windows+as+the+local+user