How to install and use httpbuilder plugin in grails

user903772 picture user903772 · Sep 11, 2011 · Viewed 9.6k times · Source

How to install and use httpbuilder plugin in Grails?

Answer

ataylor picture ataylor · Sep 11, 2011

Adding httpbuilder 0.5.1 to your application dependencies will cause errors. In particular, you'll get an error something like this:

java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.xerces.jaxp.SAXParserImpl.getParser()Lorg/xml/sax/Parser;" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/xerces/jaxp/SAXParserImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/Parser used in the signature

I think the issue is that httpbuilder is exporting it's compile-time dependencies as runtime dependencies. An easy workaround is to declare the dependency like this in your BuildConfig.groovy:

grails.project.dependency.resolution = {
    ...
    dependencies {
        runtime('org.codehaus.groovy.modules.http-builder:http-builder:0.5.1') {
            excludes 'xalan'
            excludes 'xml-apis'
            excludes 'groovy'
        }
    }
}   

I think you need mavenRepo "http://repository.codehaus.org" in the repositories section as well.