[ 
https://issues.apache.org/jira/browse/AXIS2-5044?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jean Marc updated AXIS2-5044:
-----------------------------

           Description: 
When Mapped convention is used, JSONMessageFormatter creates an XMLStreamWriter 
from Jettison library of type MappedXMLStreamWriter
and executes the following code

  XMLStreamWriter jsonWriter = getJSONWriter(bytesOut);
  element.serializeAndConsume(jsonWriter);
  jsonWriter.writeEndDocument();

at 3 places in the class (in getBytes(), getTargetAddress() and writeTo() ).
In the above code, there is no call to jsonWriter.writeStartDocument().

This works for Jettison library v1.1 and below because it does not follow the 
SAX event flow, but Jettison v1.2 and above have been refactored to respect the 
SAX event chain,
and the XMLStreamWriter expects the calling serializer to generate a 
startDocument() event at the beginning. 

Actually, the axis-json lib 1.5.4 does not specify a Maven version dependency 
on Jettison so any version should do, but with Jettison v1.2+
a simple client trying to serialize a OMElement to send a soap message triggers 
a NPE in Jettison when the last endElement() event is triggered
because the call to startDocument has never been made.

Simple solution is to add jsonWriter.writeStartDocument() before calling 
element.serializeAndConsume().
    Remaining Estimate: 5m
     Original Estimate: 5m

> JSONMessageFormatter does not call startDocument on XMLWriter with  Mapped 
> convention
> -------------------------------------------------------------------------------------
>
>                 Key: AXIS2-5044
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5044
>             Project: Axis2
>          Issue Type: Bug
>          Components: modules
>            Reporter: Jean Marc
>   Original Estimate: 5m
>  Remaining Estimate: 5m
>
> When Mapped convention is used, JSONMessageFormatter creates an 
> XMLStreamWriter from Jettison library of type MappedXMLStreamWriter
> and executes the following code
>   XMLStreamWriter jsonWriter = getJSONWriter(bytesOut);
>   element.serializeAndConsume(jsonWriter);
>   jsonWriter.writeEndDocument();
> at 3 places in the class (in getBytes(), getTargetAddress() and writeTo() ).
> In the above code, there is no call to jsonWriter.writeStartDocument().
> This works for Jettison library v1.1 and below because it does not follow the 
> SAX event flow, but Jettison v1.2 and above have been refactored to respect 
> the SAX event chain,
> and the XMLStreamWriter expects the calling serializer to generate a 
> startDocument() event at the beginning. 
> Actually, the axis-json lib 1.5.4 does not specify a Maven version dependency 
> on Jettison so any version should do, but with Jettison v1.2+
> a simple client trying to serialize a OMElement to send a soap message 
> triggers a NPE in Jettison when the last endElement() event is triggered
> because the call to startDocument has never been made.
> Simple solution is to add jsonWriter.writeStartDocument() before calling 
> element.serializeAndConsume().

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to