Grails and Amazon web services - not possible?
October 6, 2007
As of this writing, I’m having a devil of a time getting Grails (0.6 and 1.0-RC1 SNAPSHOT) to interact with the Amazon web services, uhh, service. After messing around trying to use the GroovySOAP stuff, which I couldn’t get to work (maybe I’ll go back to that?) I found the Amazon Web Services library for Java. “OK,” I thought. “I’ll just drop that in to the /lib directory, import the com.amazonws stuff and be on my way.” But it wasn’t to be.
I’m stuck on a seemingly insurmountable error. Apparently only one other person on the planet is having this problem, which doesn’t help me at all. I’m using Linux, he’s using Windows, both using JDK1.6 versions. I’ve tried Grails 0.6 and 1.0-RC1, both with groovy 1.0 and groovy 1.1 beta 3. No luck in any case. Here’s the error text I’m getting back:
Message: loader constraint violation: when resolving interface method “javax.xml.bind.Unmarshaller.unmarshal(Ljavax/xml/transform/Source;)Ljava/lang/Object;” the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, com/amazonaws/ecs/query/AmazonECSQuery, and the class loader (instance of <bootloader>) for resolved class, javax/xml/bind/Unmarshaller, have different Class objects for the type javax/xml/transform/Source used in the signature
Caused by: java.lang.LinkageError: loader constraint violation: when resolving interface method “javax.xml.bind.Unmarshaller.unmarshal(Ljavax/xml/transform/Source;)Ljava/lang/Object;” the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, com/amazonaws/ecs/query/AmazonECSQuery, and the class loader (instance of <bootloader>) for resolved class, javax/xml/bind/Unmarshaller, have different Class objects for the type javax/xml/transform/Source used in the signature
My limited reading of this and the little source code I could track down leads me to believe this is wholly insurmountable with the current setup. By that I mean this is not a configuration thing, but is an issue deep within the core of either groovy, grails or the Amazon system. I suspect that the groovy or grails team would need to budge on this if it’s to be addressed. I don’t see Amazon making accomodations for the few edge cases out there running Grails. So much for the notion that you can seamlessly drop down to Java whenever you need to. ![]()
Posted in




October 7th, 2007 at 4:02 am
If you raise an issue on the Grails JIRA and attach an app that reproduces the problem we can take a look.
Cheers,
Graeme
October 7th, 2007 at 6:28 am
Wow - I’m impressed. Elena @ AWS was able to reproduce the problem and suggested a workaround for now. Apparently the Grails system includes xerces 2.6.2, which is missing some functionality the AWS expects (I’m simplifying the answer here). Simplest workaround is to upgrade the xerces to 2.9 for now. Thanks Elena!
October 8th, 2007 at 5:09 am
Hey Graeme,
Sorry if I sounded a bit snarky. It was pretty late, and I’d wrestled with this for a long time by that point. I’m no Java expert, so hitting this bug so late in the day was pretty disheartening. You’ve already seen it - I have created a bug report already once I had Elena’s investgation notes. Also, as I wrote, the removal of the xml-apis.jar was the only thing that really seemed to work. I tried replacing xerces components with the 2.9.1 versions (couldn’t find just a xerces-2.9.1.jar) but those created their own issues. I’d urge you to try to use the amazon ecommerce aws jar yourself - http://developer.amazonwebservices.com/connect/entry.jspa?entryID=880&ref=featured has a quick tutorial and link to the jar in question - to see if proposed fixes actually fix it. Alternatively, send me your proposed fixes and I’ll give it a shot - mgkimsal@gmail.com.
Thanks for all your work on Grails - I’m in the midst of working on three projects in it, and at least one will likely become public in the next couple months. I’m looking forward to being able to share these with the community as well.
October 8th, 2007 at 7:40 am
Thanks for pushing forward on this, Mike. It’s good to see that both Amazon and the Grails team were responsive to this issue. Life on the bleeding edge can be painful at times, eh?
October 8th, 2007 at 8:36 am
NP - Graeme Rocher is doing all the heavy lifting, I’m just reporting some stuff. I’m building from SVN - graeme said he just committed a change to try to fix this. I will confirm later today if his fix worked or not.
October 9th, 2007 at 7:18 am
Awesome. I feel like I contributed in some small way, even if it was only putting the right people together at the right time. Graeme has fixed my issue - GRAILS-1679 (http://jira.codehaus.org/browse/GRAILS-1679)