title: Groovy Grape dealing with dependency resolution
body: <p>I am trying to use <code>org.xhtmlrenderer:core-renderer:R8pre2</code> in a groovy script, but I get a Linkage error:</p>
  
  <pre><code>Caught: java.lang.LinkageError: loader constraint violation in interface 
  itable initialization: when resolving method  
  "org.apache.xerces.dom.NodeImpl.getOwnerDocument()Lorg/w3c/dom/Document;" 
  the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the 
  current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of 
  &lt;bootloader&gt;) for interface org/w3c/dom/Node have different Class objects for  
  the type getOwnerDocument used in the signature
  </code></pre>
  
  <p>I've already googled a lot and found a lot of answer like these:</p>
  
  <p><a href="https://stackoverflow.com/questions/11677572/dealing-with-xerces-hell-in-java-maven">Dealing with &quot;Xerces hell&quot; in Java/Maven?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/3110258/xercesimpl-in-conflict-with-javase-6s-internal-xerces-implementation-both-are">XercesImpl in conflict with JavaSE 6&#39;s internal xerces implementation. Both are needed... what can be done?</a></p>
  
  <p>So, one solution could be to use javas <code>endorsed</code> mechanism to resolve the conflict, but I would like to make my script independent from such a "workaround". The script should run out of the box.</p>
  
  <p>Next thing I was giving a try was to exclude the right dependency like this</p>
  
  <pre><code>@Grapes([
      @Grab('org.xhtmlrenderer:core-renderer:R8pre2'),
      @GrabExclude('xml-apis:xml-apis')
  ])
  </code></pre>
  
  <p>but didn't succeed...</p>
  
  <p>Any ideas?</p>
  
  <p>PS: here is the script which creates the error:</p>
  
  <pre><code>@Grapes([
      @Grab('org.xhtmlrenderer:core-renderer:R8pre2'),
  ])
  import org.w3c.dom.Document
  import javax.xml.parsers.DocumentBuilder
  import javax.xml.parsers.DocumentBuilderFactory
  def dbf = DocumentBuilderFactory.newInstance()
  DocumentBuilder builder = dbf.newDocumentBuilder()
  Document doc = builder.parse(new ByteArrayInputStream("&lt;html&gt;&lt;/html&gt;".getBytes()))
  </code></pre>