Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3356

Groovy incompatible with 3rd party XML DOM parsers

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.6-rc-3, 2.4.3
    • None
    • groovy-jdk, XML Processing
    • None
    • Groovy 1.6.0 RC3, Java 1.6.0_10

    Description

      With Groovy versions 1.5.7 onwards there is a problem where Groovy loads
      DOM classes from the Java SDK in its RootLoader constructor.

      This makes it incompatible with XML parsing libraries having different
      versions of DOM interfaces. For example, with Oracle XML Parser I get:

      Caught: java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/NamedNodeMap"

      $groovy -e "println javax.xml.parsers.DocumentBuilderFactory.newInstance().getClass()"
      class oracle.xml.jaxp.JXDocumentBuilderFactory

      $jar tvf ~/.groovy/lib/xmlparserv2-10.2.0.2.0.jar |grep "org/w3c/dom/NamedNodeMap"
      581 Tue Dec 23 12:53:38 NZDT 2003 org/w3c/dom/NamedNodeMap.class

      $jar tvf $JAVA_HOME/jre/lib/rt.jar |grep "org/w3c/dom/NamedNodeMap"
      566 Fri Sep 26 01:22:26 NZST 2008 org/w3c/dom/NamedNodeMap.class

      This is caused by change r12189, comment:
      adds a special hack for org.w3c.dom.Node, to avoid violation of class loader constraints

      The troublesome lines are:

      // major hack here...!
      try

      { customClasses.put("org.w3c.dom.Node",super.loadClass("org.w3c.dom.Node",false)); }

      catch (Exception e) {}

      If I undo this change in trunk, I get a version of Groovy which works happily
      with the Oracle XML Parser.

      For what it's worth, I need to use the Oracle XML Parser because it contains
      code required by the Oracle XDK, required to use Oracle XML functionality in
      the JDBC driver.

      Attachments

        Activity

          People

            Unassigned Unassigned
            john.b.hurst John Hurst
            Votes:
            12 Vote for this issue
            Watchers:
            12 Start watching this issue

            Dates

              Created:
              Updated: