Announcement Announcement Module
Collapse
No announcement yet.
Bug in Oracle JAXB destroys spring-ws? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bug in Oracle JAXB destroys spring-ws?

    I think I have found a bug in the Oracle JAXB-implementation (JAXB1) which blocks spring-ws. Before I report it to Oracle, I'd like some feedback on my understanding of the issue, and also some help with a workaround.

    1) The problem

    Basically, the method oracle.xml.jaxb.JaxbMarshaller.marshal (Object obj, Result result) always adds the marshalled object to the document root, using code like this:

    Code:
    XMLNode xmlnode = (XMLNode)((DOMResult)result).getNode();
    XMLDocument xmldocument;
    if(!(xmlnode instanceof XMLDocument))
        xmldocument = (XMLDocument)xmlnode.getOwnerDocument();
    else
        xmldocument = (XMLDocument)xmlnode;
    XMLNode xmlnode1 = (XMLNode)getNode(obj);
    
    xmldocument.appendChild((XMLNode)xmldocument.adoptNode(xmlnode1));
    ((DOMResult)result).setNode(xmldocument);
    The second to last line calls document.appendChild, which always fails an exception: oracle.xml.parser.v2.XMLDOMException: "document node can have only one element node as child".

    I'm thinking that the Oracle-implementation is faulty. Do you guys agree?


    2) The workaround

    I need to work with the Oracle JAXB-implementation, so I need a workaround... This is what I did, and what seems to work:

    Code:
    public class OracleJaxb1Marshaller extends Jaxb1Marshaller {
    
        public void marshal(Object graph, Result result) {
            if (result instanceof DOMResult) {
                Node xmlnode = ((DOMResult)result).getNode();
                ContentHandler contentHandler = new DomContentHandler(xmlnode);
                try {
                    createMarshaller().marshal(graph, contentHandler);
                } catch (JAXBException ex) {
                    throw convertJaxbException(ex);
                }
            } else {
                super.marshal(graph, result);
            }
    
        }
    }
    Does this look reasonable?

    Eirik

  • #2
    Originally posted by elygre View Post
    I think I have found a bug in the Oracle JAXB-implementation (JAXB1) which blocks spring-ws. Before I report it to Oracle, I'd like some feedback on my understanding of the issue, and also some help with a workaround.
    I didn't even know Oracle had a JAXB1 marshaller, or is it the Toplink marshaller we are talking about here?


    Originally posted by elygre View Post
    1) The problem

    Basically, the method oracle.xml.jaxb.JaxbMarshaller.marshal (Object obj, Result result) always adds the marshalled object to the document root, using code like this:

    Code:
    XMLNode xmlnode = (XMLNode)((DOMResult)result).getNode();
    XMLDocument xmldocument;
    if(!(xmlnode instanceof XMLDocument))
        xmldocument = (XMLDocument)xmlnode.getOwnerDocument();
    else
        xmldocument = (XMLDocument)xmlnode;
    XMLNode xmlnode1 = (XMLNode)getNode(obj);
    
    xmldocument.appendChild((XMLNode)xmldocument.adoptNode(xmlnode1));
    ((DOMResult)result).setNode(xmldocument);
    The second to last line calls document.appendChild, which always fails an exception: oracle.xml.parser.v2.XMLDOMException: "document node can have only one element node as child".

    I'm thinking that the Oracle-implementation is faulty. Do you guys agree?
    Yes, I would agree. I don't understand the purpose of that line at all, since DOMResults can contain any Node.

    Originally posted by elygre View Post
    2) The workaround

    I need to work with the Oracle JAXB-implementation, so I need a workaround... This is what I did, and what seems to work:

    Code:
    public class OracleJaxb1Marshaller extends Jaxb1Marshaller {
    
        public void marshal(Object graph, Result result) {
            if (result instanceof DOMResult) {
                Node xmlnode = ((DOMResult)result).getNode();
                ContentHandler contentHandler = new DomContentHandler(xmlnode);
                try {
                    createMarshaller().marshal(graph, contentHandler);
                } catch (JAXBException ex) {
                    throw convertJaxbException(ex);
                }
            } else {
                super.marshal(graph, result);
            }
    
        }
    }
    Does this look reasonable?
    Sure.

    Comment


    • #3
      Originally posted by Arjen Poutsma View Post
      I didn't even know Oracle had a JAXB1 marshaller, or is it the Toplink marshaller we are talking about here?
      It's not the TopLink-implementation (which, frankly, I'm sure is much better), but rather one that comes with JDeveloper 10.1.3.

      I believe this comes from the Oracle XML Developer Kit. More info on http://www.oracle.com/technology/tech/xml/xdkhome.html, which states "Now supporting JAXB, automatically generates classes from DTDs and XML schemas to send XML from Web forms or applications".

      Anyway, thanks for a quick reply! Now on to MTOM :-)

      Comment

      Working...
      X