Installing a simple Grails application in Tomcat on Linux should really have been the most straightforward of tasks. Instead, I spent a progressively more frustrating morning chasing down a "helpful" feature of HSQLDB that was causing the startup to fail with
org.hsqldb.HsqlException: The database is already in use by another process: org.hsqldb.persist.NIOLockFile@6b67bdbe[file =/myDb.lck, exists=true, locked=false, valid=false, fl=null]
exceptions. To save others from a similar waste of time, here's the cause and a workaround:
Between versions 1.7.2. and 22.214.171.124., HSQLDB attempts to lock the files for file-based DBs in order to "[protect] the user from running the process twice with the same files and corrupting his data", apparently. Unfortunately, if your DB files reside on NFS, which doesn't support these locks, HSQLDB will blow up with the above exception. It seems that there have been enough problems with this that HSQLDB has reverted to not using locks by default in 126.96.36.199., although this may be changed again in future versions, it seems.
- Move your DB files to a non-NFS location
- Upgrade to version 188.8.131.52. (or a pre-1.7.2. version)
- Use a mem rather than a file DB
The details are described in this thread from the HSQLDB forums. From what is mentioned there, it would seem to be possible to disable file locking somehow. I tried hsqldb.nio_data_file=false, but that doesn't seem to do the trick. If anyone finds out how to do this please add a comment! Edited on 13 June 2012 to add: as pointed out in comments, it looks like I was using a slightly-too-old version and missing the hsqldb.lock_file=false option. Thanks!