Red Hat Bugzilla – Bug 974142
There is no transformer registered from java:java.io.Reader to java:javax.xml.transform.Source
Last modified: 2015-08-02 19:44:00 EDT
Description of problem:
I've got application as provided in attachment, composite with one service, wsdl interface, binding is http. One inner component, bean service with java interface, wsdl generated from this java interface. Added JAXB transformer.
Problem is, that in JAXBUnmarshalTransformer.transform() method, line 69, call on message.getContent(Source.class), it throws exception, Cannot convert from 'java.io.StringReader' to 'javax.xml.transform.Source':
No registered Transformer available for transforming from 'java:java.io.StringReader' to 'java:javax.xml.transform.Source'. A Transformer must be registered.
There is a class BasicDOMTransformer, which performs some transformations, and it should be able to do it, unfortunately it's not configured in transforms.xml in switchyard/core/transform project.
The problem is, that even if I add this transformer into my switchyard.xml by this line:
<transform:transform.java from="java:java.io.Reader" to="java:javax.xml.transform.Source" class="org.switchyard.transform.ootb.xml.BasicDOMTransformer"/>
it cannot transform it properly. The class hardly depends on DOMSource and thus it doesn't transform fom Reader to Source.
This source is needed in JAXBUnmarshalTransformer and there is no need to have exactly DOMSource, so it would be great if it can transform to javax.xml.transform.Source.
There also may be future performance issues with this DOMTransformer, if it will be the only implementation for transforming from/to xml Source.
Created attachment 760705 [details]
Attaching reproducer app
The same or similar issue is for transformation from org.w3c.dom.Element to javax.xml.transform.Source
No registered Transformer available for transforming from 'java:org.apache.xerces.dom.DeferredElementNSImpl' to 'java:javax.xml.transform.Source'. A Transformer must be registered.
org.apache.xerces.dom.DeferredElementNSImpl is implementation/subclass of org.w3c.dom.Element and then org.w3c.dom.Node, BasicDOMTransformer should be able to make this transformation, but it's not.
I forced this transformer by this line in switchyard.xml:
<transform:transform.java from="java:org.w3c.dom.Element" to="java:javax.xml.transform.Source" class="org.switchyard.transform.ootb.xml.BasicDOMTransformer"/>
I agree this can be friendlier and we can improve the coverage of transformers for this use case. I also thing we can tweak the default data type used by HttpBinding since byte is going to result in a copy of the data.
I disagree that this is a blocker since, AFAIK, this is limited to a combination of JAXB and HTTP gateway. In that scenario, the user can always introduce a converter/transformer on their own to work around the issue.
Doug - as a first pass, can you try to reproduce this on 1.1.0.CR1? I want to see if this is still an issue before talking about whether something needs to be fixed for FSW 6.0.
verified in ER6