Thursday, February 19, 2009

Oracle XMLParser and Grails - Lessons learnt

A few days ago I was trying to integrate the work of a colleague into a light Grails application I am currently maintaining but experienced classpath hell with Oracle's XMLParser V2. A better description of the problem can be found in the JIRA for the Grails project here.

The steps prescribed didn't seem to work so I thought I'd do some digging again. I'll disappoint you by telling you that the JIRA issue remains unresolved and I was only able to come up with a work around. I looked into the script for RunWar and it would appear that for some reason, Grails defaults to a non-validating parser before kicking off Jetty.

The following lines in the RunWar.groovy script for Grails-1.0.3 is telling:

System.setProperty('org.mortbay.xml.XmlParser.NotValidating','true')


This single line of code ensures that you use a non-validating parser to start up Jetty and parse your application's web.xml. Maybe if there was another means for configuring your xml parsing for Jetty in Grails it would solve the problem.

I also tried other hacky things like replacing the SAXParserFactory as suggested here but that didn't work. In the meantime I have had to make do with refactoring my classes so that they don't exchange data of xmlType directly with the database. For now Strings/Clobs will suffice until I can find an unobtrusive way of starting Jetty from Grails that will condone Oracle's XmlParser on the classpath.

Your suggestions are very welcome.

No comments: