Skip to main content

javax.xml.transform.Transformer bug?

2 replies [Last post]
Joined: 2008-10-21

Hi there,

I'm currently having a problem with the Transformer class that forced me to implement a "dirty" work-around. My objective is, starting with a SOAPMessage, being able to marshall a given node of the SOAPBody payload to an OutputStream.

I do that with the following code:

// "message" is a well-formated SOAPMessage.
SOAPBody body=message.getSOAPBody();
Node node=...
final Transformer transformer=TransformerFactory.newInstance().newTransformer();
// "output" is the OutputStream.
transformer.transform(new DOMSource(node), new StreamResult(output));

It all works fine in the unit tests and standalone execution... The problem shows up when this code is integrated in our enterprise application, that runs on Tomcat. Instead of mashalling just the node tree, the transformer is marshalling THE WHOLE document! I proved that by caching the transformer output to a ByteArrayOutputStream and inspecting the results.

Deep cloning the node, which should remove all the parent elements, also doesn't work. I removed all the legacy XML APIs (xercesImpl.jar, xml-apis.jar, etc.) and the problem still persists.

I'm using Metro 1.3 on Java 1.5.0_10 in Windows XP. Tomcat version is 5.5.23.

Did any of you kind readers experienced this behaviour before? Thank you a lot in advance, cheers,


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-12-15

If it works in your unit tests but not under Tomcat, it seems to me there's a library reference problem. I'm not familiar with how Metro is configured in the Tomcat environment. I'd suggest post a question to the Metro forum at:


Joined: 2008-10-27

I get the same issue. Did you get any success in fixing the bug?

Sansa Technology