One of the most interesting problems I worked on was a deadlock between the JVM and the Database.

This blog post is a case-study of some sorts.
I will talk about the symptoms we saw, how we analysed the problem, and the solution.

Technologies involved
A J2EE web application running on Tomcat
Oracle Database

Remind me one more time – what is a deadlock ?
Deadlock happens when two (or more ) processes have acquired  a lock and are now waiting for the other process to release its lock first- before it can proceed further. Since each process would wait for the other process to complete first- it becomes a deadlock- i.e there is no way out unless someone intervenes.Oracle will immediately detect and  break the deadlock by killing one of the process, and I believe JVM also has a similar recovery process.

So what so special about this deadlock ?
When you have a deadlock across the two systems i.e one lock exists in the JVM and another lock in Oracle, it is impossible for either system to detect it- because they simply do not know about the existence of the other lock . Each system considers it as a uni-directional lock. Uni-directional locks aren’t a problem(generally). Deadlocks are . In our case, the lock in the JVM was by the usage of a synchronized block and the lock in Oracle was because of update on one table and a pending commit.  Both these locks would exist for ever. Why? Read on…
Continue reading »


Its not always your site says anything to you

But mine did…It said ‘XDB’.

It was my grails application.This is the login window Firefox showed be gleefully with the message

The site says XDB

IE played dumb(er) – It too presented a login screen – but had a simpler message


I was in the process of trying a few things in Grails – making those cool domain classes and controllers when it happened. It was working a few minutes ago and then boom !!! it stopped.
And since I am so new to Grails- I thought maybe I had messed up something.

Surprisingly google didn’t get many results either.

Anyway it was enough to tell me the problem was with Oracle

And since I was at that time creating a new Oracle Database on my laptop- <snap> that made perfect sense. (Though I was simply creating a new database instance and not fiddling with the one that my app was using)

Once I stopped and restarted all the Oracle listeners -the problem went away.

So moral of the story ? If the site says XDB- restart your Oracle instance.

There may be more elegant solutions out there- but this is what worked for me


Grails quick-start example is a neat way to start off with Grails.

It will show you how to connect to HSQLDB and gets a quick and elementary web app up and running in no time.

But soon, I wanted to get on with the “real” stuff- Oracle

These are the changes I did to connect with Oracle (and errors I encountered on the way).

But first the Version disclaimer


Grails: 1.1

A) Changed the DataSource.groovy as follows

dataSource {
pooled = true
driverClassName = “oracle.jdbc.driver.OracleDriver”
username = “user”
password = “password”


environments {
development {
dataSource {
dbCreate = “create-drop” // one of ‘create’, ‘create-drop’,'update’
url = “jdbc:oracle:thin:@myservername:1521:mysid”
// Left test and Production as they were….

B) Dropped the oracle driver jar file in the lib folder under the grails- app folder

Bingo !!! That’s it !!!

I got only one error-  (see at the end of this post) And this maybe specific to Oracle 9i.

The fix was to add this line to the  data source.groovy


(If you are using a higher version of Oracle- you may need to use a different Dialect)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dialectDetector’: Invocation of init method failed; nested exception is Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Unsupported feature
at Method)
… 24 more
Caused by: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Unsupported feature
… 25 more
Caused by: java.sql.SQLException: Unsupported feature
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.dbaccess.DBError.throwUnsupportedFeatureSqlException(
at oracle.jdbc.OracleDatabaseMetaData.getDatabaseMajorVersion(
… 25 more
2009-04-27 10:57:39,450 [main] ERROR mortbay.log  – Failed startup of context

© 2011 Technology Cafe Suffusion theme by Sayontan Sinha