Bug 971018

Summary: Camel DefaultTypeConverter converts ByteArrayInputStream into StAXSource (RANDOMLY), which is not supported by provided jaxb implementation
Product: [JBoss] JBoss Fuse Service Works 6 Reporter: Jiri Sedlacek <jsedlace>
Component: CamelAssignee: Tomohisa Igarashi <toigaras>
Status: MODIFIED --- QA Contact: Matej Melko <mmelko>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.0 GACC: aileenc, oskutka, rcernich, soa-p-jira
Target Milestone: ER6Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reproducer none

Description Jiri Sedlacek 2013-06-05 13:21:06 UTC
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 19:48:36 UTC
Jiri, can you please retest this with the ER6 release?  Does the issue still exist?

Comment 3 Jiri Sedlacek 2013-11-13 13:03:56 UTC
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 09:15:08 UTC
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 15:30:29 UTC
Could you please attach a reproducer application?

Comment 6 Václav Chalupa 2014-12-02 16:46:49 UTC
Created attachment 963848 [details]
Reproducer

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 13:33:15 UTC
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 10:52:21 UTC
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.