Claus Ibsen created CAMEL-27394:
-----------------------------------

             Summary: camel-xsd-json - an unknown JSON field can fail with the 
Woodstox error 'Trying to write END_DOCUMENT when document has no root', and 
the real error is only suppressed
                 Key: CAMEL-27394
                 URL: https://issues.apache.org/jira/browse/CAMEL-27394
             Project: Camel
          Issue Type: Bug
          Components: camel-cxf
            Reporter: Claus Ibsen
             Fix For: 4.24.0


When {{marshal}} with {{xsdJson}} (JSON to XML) gets a JSON field that the XML 
schema does not declare, and {{ignoreUnknown}} is false, the error should be:

{noformat}
java.lang.IllegalArgumentException: The JSON field /getOrder/color is not 
declared ...
{noformat}

In the {{soap-action}} Kamelet (camel-kamelets, {{bodyFormat: json}}), the 
exchange fails with this instead:

{noformat}
com.ctc.wstx.exc.WstxOutputException: Trying to write END_DOCUMENT when 
document has no root
{noformat}

The {{IllegalArgumentException}} is only attached to it as a suppressed 
exception, so the log and the error handler show the Woodstox message, which 
does not say what is wrong. The Kamelet does a plain marshal with the WSDL as 
the schema, and the element set in the header {{CamelXsdJsonElement}}:

{code:yaml}
- marshal:
    xsdJson:
      schema: "{{wsdlURL}}"
      ignoreUnknown: "{{ignoreUnknownFields}}"
{code}

In a test route outside the Kamelet the {{IllegalArgumentException}} was the 
error thrown, with the Woodstox error suppressed, which is right. So the order 
seems to depend on how the writer is closed after the failure.

Expected: the error about the JSON field is always the one thrown, and a 
failure to close or finish the XML writer after it is only suppressed (or not 
raised at all, since the document is not complete).

Found while adding the soap-source and soap-action Kamelets to the Kamelet 
catalog (apache/camel-kamelets, 2026-11-22).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to