It seems like the latest Java update from Apple breaks the JDBC4 version of the postgresql database driver.

I currently have two Grails apps doing similar things. One (by accident or luck, your call) uses postgresql-604.jdbc3 as it’s database driver. The other one uses a different driver, namely postgres-604-jdbc4.

Today I updated my installed Java on the Mac using software update.

Suddenly one of the Grails apps was broken.

.... tries to work out what has gone wrong

I got a ClassNotFound Exception while loading the driver. So I tried to figure out where the two apps differ. It turns out that the only relevant difference between the two apps (database-driver-wise) is that one uses jdbc3 and the other jdbc4.

I’m not blaming anyone, but I suspect the update broke it.

So if anyone faces the same problem while running a Grails app, there you go: Replace jdbc4 with jdbc3!

And now part of the stacktrace for googleability:

Starting integration tests ...
Cannot load JDBC driver class 'org.postgresql.Driver'
java.lang.ClassNotFoundException: org.postgresql.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at org.codehaus.groovy.grails.cli.support.GrailsRootLoader.loadClass(GrailsRootLoader.java:45)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)

Addendum

And yes, I’m aware of the fact that the JVM on OSX is 1.5. But previously it used to work, so I figured this might still be of some use to some people. Maybe JDBC4 was a bad idea all along the way, however.

Grails + Spatial Data 2.0

May 11th, 2009

This is intended as a follow up to this artile: Grails + Spatial Data

We recently discovered (actually we were nudged in the right direction…) that one can completely do away with the manual hibernate mapping, by adding the following code to the domain class that contains spatial data:

class Event {
  String title
  String description
  Url url
  Point spatial

  static mapping = {
    columns {
      spatial type: org.hibernatespatial.GeometryUserType
    }
  }
}

I think it doesn’t get any sweeter than that.

Programming Groovy

December 11th, 2008

I will probably not this a lot, but this one is necessary. I just received my copy of the book “Programming Groovy” by Venkat Subramaniam, read it through in a few days and I gotta say:

It’s awesome!

Very clear and concise explanations. Even MOPping is explained in very short and clear examples. I like that!