Question

I've had an issue between two different Grails plugins (Drools 0.3 and WebTest) where they both seem to include some version of xml-api-* and these seem to not be able to co-exist.

What's the best way to resolve these kinds of problems?

Was it helpful?

Solution

Deleting one of the offending libs is one way but will be a pain every time you checkout the source code. Unfortunately I can't think of another way due to xml-apis not being in the plugin lib dir of WebTest but as part of the downloaded WebTest install.

Normally a plugin lib jar is not added to the classpath if it already exists in the application lib dir so you could create a dummy jar with the same name to stop one of the libs being added.

From looking at the WebTest plugin source it should be excluding xml-apis from the classpath anyway (_Events.groovy line 100) - are you using the latest version? Are you sure it's not the Drools plugin clashing with xml-apis from Grails?

There is better dependency resolution coming in 1.2 which plugins might be able to use to avoid this kind of issue in future.

OTHER TIPS

The best way to do it is using Grails dependency resolution DSL.. You can exclude offending dependancies like this:

plugin("hibernate") {
compile( 'org.hibernate:hibernate-core:3.3.1.GA') {
    excludes 'ehcache', 'xml-apis', 'commons-logging'
}
compile 'org.hibernate:hibernate-annotations:3.4.0.GA',
        'org.hibernate:hibernate-commons-annotations:3.3.0.ga'
runtime 'javassist:javassist:3.4.GA'    
}

This works since Grails 1.2. It is probable that your plug-ins are pre-Grails-1.2, otherwise internal dependency resolution mechanism based on Ivy should take care of clashes fory you. The dependency resolution DSL is no more than groovy way of writing the Ivy xml.

I'm not sure, but something to try would be to go into the directory for each of the plugins:

~/.grails/${GRAILS_VERSION}/plugins/${THE_PLUGIN}/lib

and delete the lowest version of the xml-api-*.

If you are lucky, there weren't breaking changes in the newer version of the libraries.

It seems that libs for the plugins are accessible to the entire grails app (otherwise you wouldn't be getting the conflict).

I did something similar to upgrade to a newer version of the jasper report libraries in the jasper plugin and it worked for me. You situation may be a little more complicated though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top