Deploying Multiple Grails Apps to Tomcat7

Lately I pushed my second grails app to my production tomcat server. The second app failed to startup. /var/lib/tomcat7/logs/catalina.out gave a long list of errors the first of which was…

┬áDatabase may be already in use: “Locked by another process”. Possible solutions: close all other connection(s); use the server mode [90020-173].

It turns out that the databases were named the same in the grails-app/conf/DataSource.groovy file.

The fix is to make the names of the production databases to be meaningful and thus different. For instance, change  the bold part to something different.

 

environment {
  production { 
    dataSource { 
    dbCreate = "update" 
    url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE" 

Of course after this, you’ll need to redeploy (you’ll need to replace *.war with the specific version you want to deploy).

path/to/your/grails/project $ grails war
$ cp target/*.war /var/lib/tomcat7/webapps
path/to/OTHER/grails/project $ grails war
$ cp target/*.war /var/lib/tomcat7/webapps
$ sudo /etc/init.d/tomcat7 restart

Leave a Reply

Your email address will not be published. Required fields are marked *