Jackrabbit Content Repository
  1. Jackrabbit Content Repository
  2. JCR-1755

ClassCastException when registering custom node by XML file

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: core 1.4.5
    • Fix Version/s: core 1.4.6
    • Component/s: jackrabbit-core
    • Labels:
      None
    • Environment:
      Spring 2.5, Spring Modules 0.9, Firefox 3, Tomcat 6, Ubuntu 8.10, MySql 5
      Repository is deployed as a shared J2EE resource (JNDI).

      Description

      When trying to register node type from XML file using following code:

      JackrabbitNodeTypeManager nodeTypeManager = (JackrabbitNodeTypeManager)workspace.getNodeTypeManager();
      for(Resource resource : nodeDefinitions)

      { System.out.println("** registering node:"+resource); nodeTypeManager.registerNodeTypes(resource.getInputStream(), JackrabbitNodeTypeManager.TEXT_XML); }

      we receive such surprise:

      Caused by: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
      at org.apache.jackrabbit.core.util.DOMWalker.iterateElements(DOMWalker.java:215)
      at org.apache.jackrabbit.core.nodetype.xml.NodeTypeReader.getNodeTypeDefs(NodeTypeReader.java:121)
      at org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl.registerNodeTypes(NodeTypeManagerImpl.java:257)
      at org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl.registerNodeTypes(NodeTypeManagerImpl.java:499)
      at pl.codeservice.jcr.JcrCustomNodeRegister.registerNodes(JcrCustomNodeRegister.java:41)
      at pl.codeservice.jcr.JcrCustomNodeRegister.init(JcrCustomNodeRegister.java:27)
      ...

      Registering nodes by .cnd files works fine.

        Activity

        Hide
        Jakub Wozniakowski added a comment -

        Extremely quick reaction and fix. Thank you for that.

        Show
        Jakub Wozniakowski added a comment - Extremely quick reaction and fix. Thank you for that.
        Hide
        Jukka Zitting added a comment -

        Fixed the issue in revision 698209 and merged the fix to the 1.4 branch in revision 698210. Thanks for reporting this!

        Show
        Jukka Zitting added a comment - Fixed the issue in revision 698209 and merged the fix to the 1.4 branch in revision 698210. Thanks for reporting this!
        Hide
        Jakub Wozniakowski added a comment -

        Confirmed.
        Surrounding node definitions by <nodeTypes></nodeTypes> is successfull workaround.

        Show
        Jakub Wozniakowski added a comment - Confirmed. Surrounding node definitions by <nodeTypes></nodeTypes> is successfull workaround.
        Hide
        Jukka Zitting added a comment -

        Doesn't look like a XML library version issue to me. The failing code in DOMWalker expects the parent of the currently processed XML node to be an element, but in your case it looks like it's the top-level XML document.

        We probably in any case need to fix that in DOMWalker, but I believe you can work around this issue by modifying your node type definition files. If my guess is right, your XML file looks like this:

        <nodeType ...>...</nodeType>

        Try wrapping the content in a <nodeTypes/> element, like this:

        <nodeTypes>
        <nodeType ...>...</nodeType>
        </nodeTypes>

        Show
        Jukka Zitting added a comment - Doesn't look like a XML library version issue to me. The failing code in DOMWalker expects the parent of the currently processed XML node to be an element, but in your case it looks like it's the top-level XML document. We probably in any case need to fix that in DOMWalker, but I believe you can work around this issue by modifying your node type definition files. If my guess is right, your XML file looks like this: <nodeType ...>...</nodeType> Try wrapping the content in a <nodeTypes/> element, like this: <nodeTypes> <nodeType ...>...</nodeType> </nodeTypes>
        Hide
        Jakub Wozniakowski added a comment -

        Using Sun Java 1.5.0.15

        Show
        Jakub Wozniakowski added a comment - Using Sun Java 1.5.0.15
        Hide
        Alexander Klimetschek added a comment -

        Oh, and Jackrabbit uses/requires xerces version 2.8.1

        Show
        Alexander Klimetschek added a comment - Oh, and Jackrabbit uses/requires xerces version 2.8.1
        Hide
        Alexander Klimetschek added a comment -

        Looks like the classical "container or JVM provides different XML implementation (Xerces version)" than expected, ie. from what is provided in Jackrabbit's lib.

        Show
        Alexander Klimetschek added a comment - Looks like the classical "container or JVM provides different XML implementation (Xerces version)" than expected, ie. from what is provided in Jackrabbit's lib.

          People

          • Assignee:
            Jukka Zitting
            Reporter:
            Jakub Wozniakowski
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development