Wednesday, January 20, 2010

GeoServer Doesn't Start with a Corrupted Coordinate System DB

This week I ran into a problem in our CI (Continuous Integration) environment that really had me stumped for a while. I wanted to post the outcome in case anyone else sees similar behavior and is in search of the solution.

We''ve been using the open source map server GeoServer for a while on at least two different projects. Let me say first, that I think the GeoServer team is doing a wonderful job and has produced a very function, flexible, and stable solution. Earlier this week I had checked in configuration changes that added additional data to our default deployment. The next time that our CI environment rebuilt and redeployed GeoServer it failed to start with an out of memory error. I thought, no problem I'll adjust the JVM initialization parameters and restart. At this point, I received the following exception during startup and the application failed to deploy.

org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:4326" from authority "European Petroleum Survey Group" found for object of type "IdentifiedObject"

An EPSG is a common way of representing the coordinate system that spatial data is associated with. Since new data was recently added, my initial thought was that I madea mistake configuring the new data. The wierd thing was that the EPSG code referenced, 4326, corresponds to one of the most commonly used coordinate systems used with spatial data. If it wasn't available, somethign larger was going on. After sifting through a number of log files, news group posts, etc it appeared that the most likely culprit was an HSQLDB database that is written to disk by GeoServer to aid in coordinate system look-ups. If the database exists, but is corrupted GeoServer will not be able to read it and will indicate that it can't determine referenced coordinate systems. The solution is easy to delete these files and let them be recreated on the next restart. Locating the files was a little challenging. Below are the locations where I have seen the files being written. Delete all of the files in the directory, restart, and the problem should go away.

UNIX/Linux:
/tmp/Geotools/Databases/HSQL

Windows:
%SystemDrive%\Documents and Settings\\Local Settings\tmp\Geotools\Databases\HSQL\


or

%SystemRoot%\tmp\Geotools\Databases\HSQL