Tuesday, April 20, 2010

Using excludes while dependency resolution in grails 1.2

http://www.pither.com/articles/2010/02/01/dependency-excludes-in-grails-1.2:
http://www.grails.org/doc/latest/guide/3.%20Configuration.html#3.7%20Dependency%20Resolution

Trying to upgrade a grails 1.1.1 app to 1.2.1.
Without excluding xml-apis.jar in buildConfig.groovy dependency configs one gets an:

Error executing script Upgrade: loader constraint violation: loader (instance of ) previously initiated loading for a different type with
name "org/xml/sax/SAXParseException"
java.lang.LinkageError: loader constraint violation: loader (instance of ) previously initiated loading for a different type with name "or
g/xml/sax/SAXParseException"
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
        at java.lang.Class.getDeclaredMethods(Class.java:1791)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:33)
        at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:20)
        at _PluginDependencies_groovy.readMetadataFromZip(_PluginDependencies_groovy:922)
        at _PluginDependencies_groovy.this$4$readMetadataFromZip(_PluginDependencies_groovy)
        at _PluginDependencies_groovy$_run_closure24.doCall(_PluginDependencies_groovy:911)
        at _PluginDependencies_groovy$_run_closure31_closure87.doCall(_PluginDependencies_groovy:1208)
        at _PluginDependencies_groovy$_run_closure31_closure87.doCall(_PluginDependencies_groovy)
        at _PluginDependencies_groovy.withPluginInstall(_PluginDependencies_groovy:1253)
        at _PluginDependencies_groovy.this$4$withPluginInstall(_PluginDependencies_groovy)
        at _PluginDependencies_groovy$_run_closure31.doCall(_PluginDependencies_groovy:1207)
        at _PluginDependencies_groovy$_run_closure31.call(_PluginDependencies_groovy)
        at _GrailsPlugins_groovy$_run_closure3.doCall(_GrailsPlugins_groovy:96)
        at Upgrade$_run_closure1.doCall(Upgrade.groovy:215)
        at Upgrade$_run_closure2.doCall(Upgrade.groovy:223)
        at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
        at gant.Gant.withBuildListeners(Gant.groovy:344)
        at gant.Gant.this$2$withBuildListeners(Gant.groovy)
        at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
        at gant.Gant.dispatch(Gant.groovy:334)
        at gant.Gant.this$2$dispatch(Gant.groovy)
        at gant.Gant.invokeMethod(Gant.groovy)
        at gant.Gant.processTargets(Gant.groovy:495)
        at gant.Gant.processTargets(Gant.groovy:480)
Error executing script Upgrade: loader constraint violation: loader (instance of ) previously initiated loading for a different type with
name "org/xml/sax/SAXParseException"

My buidConfig is:


//grails.project.class.dir = "target/classes"
//grails.project.test.class.dir = "target/test-classes"
//grails.project.test.reports.dir = "target/test-reports"
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits( "global" ) {
        // uncomment to disable ehcache
        // excludes 'ehcache'
excludes "junit", "xml-apis", "xercesImpl"
}
    log "verbose" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    repositories {      
        grailsPlugins()
        grailsHome()

        // uncomment the below to enable remote dependency resolution
        // from public Maven repositories
        mavenLocal()
        mavenCentral()
        mavenRepo "http://snapshots.repository.codehaus.org"
        mavenRepo "http://repository.codehaus.org"
        mavenRepo "http://download.java.net/maven/2/"
        mavenRepo "http://repository.jboss.com/maven2/"
mavenRepo "http://jansi.fusesource.org/repo/release/"

    }
    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
runtime 'mysql:mysql-connector-java:5.1.6'
runtime 'net.sf.ezmorph:ezmorph:1.0.6'
runtime 'net.sf.ehcache:ehcache:1.5.0'
runtime 'org.slf4j:slf4j-log4j12:1.5.5'

runtime ('org.codehaus.groovy:http-builder:0.5.0-SNAPSHOT',
){
excludes "junit", "xml-apis", "xercesImpl"
}
runtime('opensymphony:oscache:2.4'){
excludes "javax.jms", "commons-logging", "javax.servlet"
}
//build 'org.json:json:20080701'
build 'javax.servlet:servlet-api:2.5'
build 'net.sf.json-lib:json-lib:2.2.3'
build ('org.apache.xmlrpc:xmlrpc-client:3.1',
'org.apache.xmlrpc:xmlrpc-server:3.1',
'org.apache.ws.commons.util:ws-commons-util:1.0.2'){
excludes "junit", "xml-apis", "xercesImpl"
}
}
}

No comments:

Post a Comment