LinkageError when processing XML (dom)

Hi,

I would like to create gradle plugin, which can add a copyright statement as comment into existing XML.

That’s why normal groovy XMLParser/Slurper doesn’t help, they don’t respect xml-comments… So I tried to use
Document document = DOMBuilder.parse(new FileReader(myXmlFile))
but that results in:

java.lang.LinkageError: loader constraint violation in interface itable initialization for class org.apache.xerces.dom.NodeImpl: when selecting method org.w3c.dom.Node.getChildNodes()Lorg/w3c/dom/NodeList; the class loader for super interface org.w3c.dom.Node, and the class loader “” (instance of org.codehaus.groovy.tools.RootLoader@4141d797, child of sun.misc.Launcher$AppClassLoader@446cdf90) of the selected method’s type, org.apache.xerces.dom.NodeImpl have different Class objects for the type org.w3c.dom.NodeList used in the signature

How can I fix this?

Thanks,
Hilmar