users@jersey.java.net

Re: [Jersey] JsonGenerationException: Can not write text value, expecting field name

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Wed, 10 Jun 2009 17:58:35 -0400

On further analysis it appears that the use of schema extensibility in highlighted section below from rim.xsd may be the problem. Perhaps the JSONMarshaller does not handle such schema extensibility correctly?

 <complexType name="AnyValueType">
    <annotation>
      <documentation xml:lang="en">
        A specialized ValueType that may be used as a container for any well-formed XML element value in any namespace.
        Use this to specify an XML element as the value for a Slot.
      </documentation>
    </annotation>
    <complexContent>
      <extension base="tns:ValueType">
        <sequence>
          <any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="1"/>
        </sequence>
      </extension>
    </complexContent>
  </complexType>

This would cause the highlighted section below to not be marshalled properly:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtrinsicObject
  xmlns="urn:oasis:names:tc:ebxml-regrep:xsd:rim:4.0"
  xmlns:ns2="http://www.w3.org/1999/xlink"
  xmlns:ns3="http://www.w3.org/2005/08/addressing"
  xmlns:ns4="urn:oasis:names:tc:ebxml-regrep:xsd:query:4.0"
  xmlns:ns5="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:4.0"
  xmlns:ns6="urn:oasis:names:tc:ebxml-regrep:xsd:spi:4.0"
  xmlns:ns7="urn:oasis:names:tc:ebxml-regrep:xsd:rs:4.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="urn:oasis:names:tc:ebxml-regrep:xsd:rim:4.0  http://www.wellfleetsoftware.com/files/rim.xsd"
  mimeType="text/xml" status="urn:oasis:names:tc:ebxml-regrep:StatusType:Submitted"
  objectType="urn:iso:TC211:19115:profile:ObjectType:MD_MetaData"
  lid="urn:foo:Dataset:Lightning-1:metadata"
  id="urn:foo:Dataset:Lightning-1:metadata">
    <Slot dataType="urn:ogc:def:dataType:ISO-19107:GM_Envelope" name="urn:iso:TC211:19115:slot:geographicBoundingBox">
        <ValueList>
            <ValueListItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AnyValueType">
                <ns1:Polygon xmlns:ns1="http://www.opengis.net/gml/3.2" xmlns:ns4="http://www.isotc211.org/2005/gco" xmlns:ns3="http://www.isotc211.org/2005/gmd" xmlns:ns5="http://www.isotc211.org/2005/gmx" xmlns:ns6="http://www.isotc211.org/2005/gts" ns1:id="">
                    <ns1:exterior>
                        <ns1:LinearRing>
                            <ns1:posList>-120.0 25.0 -70.0 25.0 -70.0 40.0 -120.0 40.0 -120.0 25.0</ns1:posList>
                        </ns1:LinearRing>
                    </ns1:exterior>
                </ns1:Polygon>
            </ValueListItem>
        </ValueList>
    </Slot>
</ExtrinsicObject>


Farrukh Najmi wrote:

I have narrowed the problem down.

The following XML file shows XML representation of my JAXB object:

<http://www.wellfleetsoftware.com/files/LightningDataset.xml>

When marshalling above to JSON, it appears that the Jackson code chokes when Stax2JacksonWriter writes the  following content of the <ns1:posList> element's body:

-120.0 25.0 -70.0 25.0 -70.0 40.0 -120.0 40.0 -120.0 25.0

Hopefully someone more knowledgeable than I would spot what could be wrong and how to fix it.

Thanks.


Jakub Podlesak wrote:
Tatu Saloranta wrote:

I don't know how troubleshooting would work, but definitely writing a
simple (as simple as possible) unit test to reproduce would allow it
to be fixed.
 

+1

Farrukh, sending out such a test case would be the most helpful,





-- 
Regards,
Farrukh

Web: http://www.wellfleetsoftware.com