Apache Derby on Mac OS X

Earlier this week I got an email from John Tangney, a user of nntp//rss, reporting a problem running the latest release on Mac OS X. After some investigation, it materializes that the problem is actually related to Apache Derby, the new embedded database within nntp//rss as of v0.5-beta-1.

Derby was failing on the first startup, with the following exception written to derby.log:

java.io.FileNotFoundException: /usr/local/nntprss-0.5-beta-1/nntprssdb/log/log1.dat (File exists)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.(RandomAccessFile.java:204)
at org.apache.derby.impl.io.DirRandomAccessFile.(DirRandomAccessFile.java)
at org.apache.derby.impl.io.DirRandomAccessFile4.(DirRandomAccessFile4.java)

A bit of prodding around in the Derby code showed that it was trying to initialize its subclass of java.io.RandomAccessFile with the sync mode ‘rws’. I had not experienced any difficulties on Windows or Linux with Derby, so I started up a copy on Mac OS X 10.3.6, and, low and behold, got the same exception. A bit of judicious Googling finally turned up this IBM developerWorks forum post. Looking in Apache JIRA, I found this report (and extensive conversation) related to the bug, which basically identifies it as a Mac JVM issue. Unfortunately, to date, there has been no resolution from Apple.

Fortunately Derby has a property, derby.storage.fileSyncTransactionLog, which can be set to true to workaround this issue. For example, nntp//rss on Mac OS X should be started with the following command:

java -Dderby.storage.fileSyncTransactionLog=true -jar nntprss-start.jar

If you’re developing a Mac OS X application using Derby, you can also set this property within your code, before initializing the Derby driver. The System-Wide Properties section of the Derby documentation provides more details.

This entry was posted in Java. Bookmark the permalink.

3 Responses to Apache Derby on Mac OS X

  1. [PS-420] Change embedded database from Pointbase to Cloudscape/Derby

    Derby is hit by a bug in the Mac JVM which can be worked around – see this post http://www.jasonbrome.com/blog/archives/2004/12/05/apache_derby_on_mac_os_x.html

  2. Todd Brackett says:

    This is no longer an issue in Mac OS X v10.4 Tiger.

  3. It is still an issue with Tiger, on Java 1.5 but not 1.4.x. See: http://db.apache.org/derby/faq.html

Comments are closed.