Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-514

JSONProvider - default setting of serializeAsArray is true, leading to marshaling error in out-of-the-box CXF configuration

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.5.1
    • Component/s: None
    • Labels:

      Description

      Referring to this thread: http://openejb.979440.n4.nabble.com/Possible-JSON-bug-in-TomEE-1-5-and-1-5-1-td4658328.html it appears that the default setting of serializeAsArray is set to true for the standard CXF JSONParser.

      This appears to lead to the situation where even the root-objet of the marshaled object tree is formatted as an array. The CXF Unmarshaler (not sure which class is doing this exactly) fails if root object is formatted as an array (I have experienced this error in the case where my root object was NOT a collection).

      Example:

      class MyObject {
      String id;
      }

      is marshaled as (square braces '[' indicate an array):

      {"myobjectinstance:[

      {"id":"12345}

      ]}

      and the webmethod "receiving" the MyObject that is formatted with the square braces will fail:

      @Consumes("application/json")
      @POST
      @Path("/process")
      public MyObject process(MyObject myObjectInstance) {
      ...
      }

      So solution could be

      • to set serializeAsArray to false or
      • somehow in other way ensure that single instances in json are formatted as such,
      • or make standard CXF json unmarshaler more tolerant with single instances formatted as an array.

      br
      Reinis

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              reinis_v Reinis Vicups
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: