Bug 971018 - Camel DefaultTypeConverter converts ByteArrayInputStream into StAXSource (RANDOMLY), which is not supported by provided jaxb implementation
Camel DefaultTypeConverter converts ByteArrayInputStream into StAXSource (RAN...
Product: JBoss Fuse Service Works 6
Classification: JBoss
Component: Camel (Show other bugs)
6.0.0 GA
Unspecified Unspecified
unspecified Severity high
: ER6
: ---
Assigned To: Tomohisa Igarashi
Matej Melko
: Reopened
Depends On:
  Show dependency treegraph
Reported: 2013-06-05 09:21 EDT by Jiri Sedlacek
Modified: 2015-11-02 03:03 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Reproducer (12.39 KB, application/zip)
2014-12-02 11:46 EST, Václav Chalupa
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker SWITCHYARD-2511 Major Open JAXB unmarshal fails with StAXSource produced by camel converter 2015-02-02 05:52:21 EST

  None (edit)
Description Jiri Sedlacek 2013-06-05 09:21:06 EDT
Problem background: 

Switchyard composite, WSDL interface as a service, inside bean component with java interface, between composite service and component service are autogenerated JAXB transformers.

Camel file binding is used.

When I put file in directory specified in file binding, it starts to process it and throws following exception:

Caught exception of type java.lang.IllegalArgumentException with message: null: java.lang.IllegalArgumentException
	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:109) [jboss-jaxb-api_2.2_spec-1.0.4.Final-redhat-2.jar:1.0.4.Final-redhat-2]
	at org.switchyard.transform.jaxb.internal.JAXBUnmarshalTransformer.transform(JAXBUnmarshalTransformer.java:79) [switchyard-transform-0.8.1.Final.jar:0.8.1.Final]
	at org.switchyard.transform.jaxb.internal.JAXBUnmarshalTransformer.transform(JAXBUnmarshalTransformer.java:43) [switchyard-transform-0.8.1.Final.jar:0.8.1.Final]
	at org.switchyard.transform.TransformSequence.apply(TransformSequence.java:125) [switchyard-api-0.8.1.Final.jar:0.8.1.Final]
	at org.switchyard.transform.TransformSequence.applySequence(TransformSequence.java:213) [switchyard-api-0.8.1.Final.jar:0.8.1.Final]
	at org.switchyard.handlers.TransformHandler.handleMessage(TransformHandler.java:95) [switchyard-runtime-0.8.1.Final.jar:0.8.1.Final]
	at org.switchyard.bus.camel.processors.HandlerProcessor.process(HandlerProcessor.java:69) [switchyard-bus-camel-0.8.1.Final.jar:0.8.1.Final]
	at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.10.0.jar:2.10.0]
	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]
	at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

After diging in the code, I realized, that javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:109) expects SAXSource, DOMSource or StreamSource, but there is passed StAXSource. It seems that problem is in camel DefaultTypeConverter, which transforms the the message content into StAXSource. 

After several restarts of server I realized, that method 

BaseTypeConverterRegistry.getOrFindTypeConverter(Class<?> toType, Object value)

sometimes returns DOMSource, sometimes StreamSource and sometimes problematic StAXSource. It probably depends on startup initialization of converter registry.
Comment 1 kconner 2013-11-07 14:48:36 EST
Jiri, can you please retest this with the ER6 release?  Does the issue still exist?
Comment 3 Jiri Sedlacek 2013-11-13 08:03:56 EST
I ran several times and no StaXSource passed anymore, just DOMSource, StreamSource and SAXSource, so I hope it's fixed.

Marking as verified in ER6.
Comment 4 Václav Chalupa 2014-05-22 05:15:08 EDT
This issue still occurs. I have found it for ftp inbound binding.

StAXSource is returned by java:java.io.ByteArrayInputStream -> java:javax.xml.transform.Source transformation and IllegalArgumentException is thrown in javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:109).
Comment 5 Rob Cernich 2014-10-14 11:30:29 EDT
Could you please attach a reproducer application?
Comment 6 Václav Chalupa 2014-12-02 11:46:49 EST
Created attachment 963848 [details]

I could finally create a reproducer. You have to set dir, host, username, password to ftp bindings (service, reference).

Restart EAP many times, deploy and run the reproducer. You should see the issue.
Comment 7 Keith Babo 2015-01-28 08:33:15 EST
I guess one option would be to add protective logic inside of JAXBUnmarshalTransformer to check for StAXSource and convert it directly to another acceptable Source type.
Comment 8 Tomohisa Igarashi 2015-02-02 05:52:21 EST
It seems we need to avoid letting camel convert to Source as it has some issues. Instead, just converting it to StreamSource directly solves the problem. I tested many times with it and no failure so far.

Note You need to log in before you can comment on or make changes to this bug.