users@jersey.java.net

JavaOne week <was> Re: [Jersey] JsonGenerationException: Can not write text value, expecting field name

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 01 Jun 2009 13:21:23 -0700

Hi Farrukh,

As you may it is JavaOne this week, so we may not get around to
working out what is wrong... plus Jakub will be away the week after.
All i can suggest for the moment is to create a reproducible test case
and attach it to an issue.

The error is originating from Jackson, but i reckon it may be the way
Jersey uses Jackson and the information that is passed to it for
certain values.

Paul.


On Jun 1, 2009, at 10:48 AM, Farrukh Najmi wrote:

> Hi Guys,
>
> My jersey 1.1.1-ea-SNAPSHOT based server returns an XML document in
> response to a request that specifies a query when the query
> parameter "format=application/xml". It returns the equivalent JSON
> document when the query parameter "format=application/json".
>
> Thing work for certain queries fine. However, on certain queries I
> get the following stack trace below for "format=application/json"
> but not for "format=application/xml".
>
> I tried turning on jersey logging using Jakub's suggestion here:
>
> <http://markmail.org/message/qwb57fksrtueox7h#query:jersey%20java%20logging+page:1+mid:fcmc5xvktvcrutns+state:results
> >
>
> I did not see any log output.
>
> Any suggestions on how best to debug this?
>
> java.io.IOException: Error marshalling JAXB object of type "class
> org.freebxml.omar.jaxb.bindings.query._4_0.QueryResponse".
>
> com
> .sun
> .jersey
> .core
> .provider
> .jaxb
> .AbstractRootElementProvider
> .writeTo(AbstractRootElementProvider.java:145)
>
> com
> .sun
> .jersey.spi.container.ContainerResponse.write(ContainerResponse.java:
> 254)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:693)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:616)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:607)
>
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.service(WebComponent.java:
> 309)
>
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:425)
>
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:590)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
> org
> .netbeans
> .modules
> .web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
>
> *root cause*
>
> javax.xml.bind.MarshalException
> - with linked exception:
> [net.sf.saxon.trans.DynamicError:
> javax.xml.stream.XMLStreamException:
> org.codehaus.jackson.JsonGenerationException: Can not write text
> value, expecting field name]
>
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:
> 328)
>
> com
> .sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:
> 172)
> com.sun.jersey.json.impl.JSONMarshaller.marshal(JSONMarshaller.java:
> 123)
>
> com
> .sun
> .jersey
> .json
> .impl
> .provider
> .entity.JSONRootElementProvider.writeTo(JSONRootElementProvider.java:
> 139)
>
> com
> .sun
> .jersey
> .core
> .provider
> .jaxb
> .AbstractRootElementProvider
> .writeTo(AbstractRootElementProvider.java:143)
>
> com
> .sun
> .jersey.spi.container.ContainerResponse.write(ContainerResponse.java:
> 254)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:693)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:616)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:607)
>
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.service(WebComponent.java:
> 309)
>
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:425)
>
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:590)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
> org
> .netbeans
> .modules
> .web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
>
> *root cause*
>
> net.sf.saxon.trans.DynamicError:
> javax.xml.stream.XMLStreamException:
> org.codehaus.jackson.JsonGenerationException: Can not write text
> value, expecting field name
>
> com
> .sun
> .xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:245)
>
> com
> .sun
> .xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:260)
>
> com
> .sun.xml.bind.v2.runtime.XMLSerializer.writeDom(XMLSerializer.java:
> 809)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .SingleReferenceNodeProperty
> .serializeBody(SingleReferenceNodeProperty.java:109)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 332)
>
> com
> .sun
> .xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:
> 698)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .ArrayElementNodeProperty
> .serializeItem(ArrayElementNodeProperty.java:65)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:
> 152)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 332)
>
> com
> .sun
> .xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:
> 698)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .SingleElementNodeProperty
> .serializeBody(SingleElementNodeProperty.java:152)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 332)
>
> com
> .sun
> .xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:
> 698)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .ArrayElementNodeProperty
> .serializeItem(ArrayElementNodeProperty.java:65)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:
> 152)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 332)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 328)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 328)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 328)
>
> com
> .sun
> .xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:
> 698)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .ArrayElementNodeProperty
> .serializeItem(ArrayElementNodeProperty.java:65)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:
> 152)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 332)
>
> com
> .sun
> .xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:
> 698)
>
> com
> .sun
> .xml
> .bind
> .v2
> .runtime
> .property
> .SingleElementNodeProperty
> .serializeBody(SingleElementNodeProperty.java:152)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 332)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:
> 328)
>
> com
> .sun
> .xml
> .bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:
> 592)
>
> com
> .sun
> .xml
> .bind
> .v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:
> 320)
>
> com
> .sun
> .xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:493)
>
> com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:
> 325)
>
> com
> .sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:
> 172)
> com.sun.jersey.json.impl.JSONMarshaller.marshal(JSONMarshaller.java:
> 123)
>
> com
> .sun
> .jersey
> .json
> .impl
> .provider
> .entity.JSONRootElementProvider.writeTo(JSONRootElementProvider.java:
> 139)
>
> com
> .sun
> .jersey
> .core
> .provider
> .jaxb
> .AbstractRootElementProvider
> .writeTo(AbstractRootElementProvider.java:143)
>
> com
> .sun
> .jersey.spi.container.ContainerResponse.write(ContainerResponse.java:
> 254)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:693)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:616)
>
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:607)
>
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.service(WebComponent.java:
> 309)
>
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:425)
>
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:590)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
> org
> .netbeans
> .modules
> .web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
>
>
> --
> Regards,
> Farrukh
>
> Web: http://www.wellfleetsoftware.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>