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:
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".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);
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:
Does this look reasonable?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); } } }
Eirik


Reply With Quote
