dev@jersey.java.net

RE: [Jersey] .reader.Jackson2StaxReader getAttributeCount Exception

From: Sanjay Shrivastava <ssusa_at_hotmail.com>
Date: Fri, 22 May 2009 20:48:55 +0000

hi Paul,
Do you need more info, can you let me know what is the issue ?

-Sanjay

From: ssusa_at_hotmail.com
To: paul.sandoz_at_sun.com; dev_at_jersey.dev.java.net
Subject: RE: [Jersey] .reader.Jackson2StaxReader getAttributeCount Exception
Date: Fri, 22 May 2009 17:51:18 +0000








On the server side REST service method is simple.

        @Consumes ({"application/json", "application/xml"})
       // @Consumes ("application/xml")
      // @Consumes ("application/json")
        public void addData(@QueryParam("xyzID") String p_componentID,DataWrapperType p_dataObject) throws WebApplicationException

-Sanjay

From: ssusa_at_hotmail.com
To: paul.sandoz_at_sun.com; dev_at_jersey.dev.java.net
Subject: RE: [Jersey] .reader.Jackson2StaxReader getAttributeCount Exception
Date: Fri, 22 May 2009 17:45:42 +0000








Hi Paul,
Thanks for quick reply, I am using 1.0.3.
I am using simple JAXB objects wrapper

  <xsd:element name="dataWrapper" type="dataWrapperType"/>
  <xsd:complexType name="dataWrapperType">
  <xsd:sequence>
      <xsd:element name="componentType" type="xsd:string"> </xsd:element>
      <xsd:element name="genObject" type="xsd:anyType"></xsd:element>
  </xsd:sequence>
 </xsd:complexType>

GenObject holds other objects like Flights example what you have, it works fine

        ClientResponse response = webResource.path("xyzservice").queryParam("xyzID", IDValue).type(MediaType.APPLICATION_XML).post(ClientResponse.class, dataWrapper);

It fails if change media type to something like this

        ClientResponse response =
webResource.path("xyzservice").queryParam("xyzID",
IDValue).type("application/json").post(ClientResponse.class,
dataWrapper);

Thanks

-Sanjay


> Date: Fri, 22 May 2009 08:58:45 +0200
> From: Paul.Sandoz_at_Sun.COM
> Subject: Re: [Jersey] .reader.Jackson2StaxReader getAttributeCount Exception
> To: dev_at_jersey.dev.java.net
> CC: ssusa_at_hotmail.com
>
> Hi Sanju,
>
> What version of Jersey are you using? 1.0.3 or 1.1.0-ea ?
>
> Can you please send more information on the JAXB objects you are
> using, preferably some code that reproduces the test case.
>
> Paul.
>
>
> On May 22, 2009, at 4:48 AM, sanju wrote:
>
> >
> > Hi All,
> > I am getting following exception when trying to use REST/HTTP PUT
> > operation with JSON MIME type ( while the same PUT operation works
> > fine for the same REST service)
> > May 21, 2009 7:16:12 PM
> > com.sun.jersey.json.impl.reader.Jackson2StaxReader getAttributeCount
> > SEVERE: null
> > java.io.IOException: Not an attribute, expected primitive value!
> > at
> > com
> > .sun
> > .jersey
> > .json
> > .impl.reader.Jackson2StaxReader.readNext(Jackson2StaxReader.java:145)
> > at
> > com
> > .sun
> > .jersey
> > .json
> > .impl
> > .reader.Jackson2StaxReader.getAttributeCount(Jackson2StaxReader.java:
> > 301)
> > at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector
> > $1.getLength(StAXStreamConnector.java:250)
> > at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector
> > $1.getIndex(StAXStreamConnector.java:280)
> > at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor
> > $AttributesImpl.getIndex(InterningXmlVisitor.java:112)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime.unmarshaller.XsiTypeLoader.parseXsiType(XsiTypeLoader.java:
> > 82)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime.unmarshaller.XsiTypeLoader.startElement(XsiTypeLoader.java:
> > 67)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller
> > .UnmarshallingContext._startElement(UnmarshallingContext.java:481)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller
> > .UnmarshallingContext.startElement(UnmarshallingContext.java:459)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller
> > .InterningXmlVisitor.startElement(InterningXmlVisitor.java:71)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller
> > .StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
> > at
> > com
> > .sun
> > .jersey.json.impl.JSONUnmarshaller.unmarshal(JSONUnmarshaller.java:
> > 100)
> > at
> > com
> > .sun
> > .jersey
> > .json
> > .impl
> > .provider
> > .entity
> > .JSONRootElementProvider.readFrom(JSONRootElementProvider.java:104)
> > at
> > com
> > .sun
> > .jersey
> > .core
> > .provider
> > .jaxb
> > .AbstractRootElementProvider
> > .readFrom(AbstractRootElementProvider.java:97)
> > at
> > com
> > .sun
> > .jersey
> > .spi.container.ContainerRequest.getEntity(ContainerRequest.java:391)
> > at
> > com
> > .sun
> > .jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider
> > $EntityInjectable.getValue(EntityParamDispatchProvider.java:81)
> > at
> > com
> > .sun
> > .jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider
> > $EntityParamInInvoker.getParams(EntityParamDispatchProvider.java:99)
> > at
> > com
> > .sun
> > .jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider
> > $VoidOutInvoker._dispatch(EntityParamDispatchProvider.java:120)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .model
> > .method
> > .dispatch
> > .ResourceJavaMethodDispatcher
> > .dispatch(ResourceJavaMethodDispatcher.java:67)
> > at
> > com
> > .sun
> > .jersey
> > .server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:154)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .uri
> > .rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .application
> > .WebApplicationImpl._handleRequest(WebApplicationImpl.java:543)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .application
> > .WebApplicationImpl.handleRequest(WebApplicationImpl.java:502)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .application
> > .WebApplicationImpl.handleRequest(WebApplicationImpl.java:493)
> > at
> > com
> > .sun
> > .jersey.spi.container.servlet.WebComponent.service(WebComponent.java:
> > 308)
> > at
> > com
> > .sun
> > .jersey
> > .spi
> > .container.servlet.ServletContainer.service(ServletContainer.java:314)
> > at
> > com
> > .sun
> > .jersey
> > .spi
> > .container.servlet.ServletContainer.service(ServletContainer.java:239)
> > at
> > org
> > .apache
> > .catalina
> > .core
> > .ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
> > 290)
> > at
> > org
> > .apache
> > .catalina
> > .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> > at
> > org
> > .apache
> > .catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
> > 228)
> > at
> > org
> > .apache
> > .catalina.core.StandardContextValve.invoke(StandardContextValve.java:
> > 175)
> > at
> > org
> > .apache
> > .catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> > at
> > org
> > .apache
> > .catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
> > at
> > org
> > .apache
> > .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
> > 109)
> > at
> > org
> > .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
> > 212)
> > at
> > org
> > .apache.coyote.http11.Http11Processor.process(Http11Processor.java:
> > 844)
> > at org.apache.coyote.http11.Http11Protocol
> > $Http11ConnectionHandler.process(Http11Protocol.java:634)
> > at org.apache.tomcat.util.net.JIoEndpoint
> > $Worker.run(JIoEndpoint.java:445)
> > at java.lang.Thread.run(Thread.java:619)
> > May 21, 2009 7:16:12 PM
> > org.apache.catalina.core.StandardWrapperValve invoke
> > SEVERE: Servlet.service() for servlet JerseyRestServlet threw
> > exception
> > java.lang.NullPointerException
> > at
> > com
> > .sun
> > .org
> > .apache.xalan.internal.xsltc.trax.SAX2DOM.startElement(SAX2DOM.java:
> > 195)
> > at
> > com
> > .sun
> > .org
> > .apache
> > .xml
> > .internal
> > .serializer.ToXMLSAXHandler.closeStartTag(ToXMLSAXHandler.java:204)
> > at
> > com
> > .sun
> > .org
> > .apache
> > .xml.internal.serializer.ToSAXHandler.flushPending(ToSAXHandler.java:
> > 277)
> > at
> > com
> > .sun
> > .org
> > .apache
> > .xml
> > .internal.serializer.ToXMLSAXHandler.endElement(ToXMLSAXHandler.java:
> > 243)
> > at
> > com
> > .sun
> > .org
> > .apache
> > .xalan
> > .internal
> > .xsltc
> > .trax.TransformerHandlerImpl.endElement(TransformerHandlerImpl.java:
> > 273)
> > at
> > com
> > .sun
> > .xml
> > .bind.v2.runtime.unmarshaller.DomLoader.leaveElement(DomLoader.java:
> > 150)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller
> > .UnmarshallingContext.endElement(UnmarshallingContext.java:506)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller
> > .InterningXmlVisitor.endElement(InterningXmlVisitor.java:77)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller
> > .StAXStreamConnector.handleEndElement(StAXStreamConnector.java:217)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:181)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
> > at
> > com
> > .sun
> > .xml
> > .bind
> > .v2
> > .runtime
> > .unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
> > at
> > com
> > .sun
> > .jersey.json.impl.JSONUnmarshaller.unmarshal(JSONUnmarshaller.java:
> > 100)
> > at
> > com
> > .sun
> > .jersey
> > .json
> > .impl
> > .provider
> > .entity
> > .JSONRootElementProvider.readFrom(JSONRootElementProvider.java:104)
> > at
> > com
> > .sun
> > .jersey
> > .core
> > .provider
> > .jaxb
> > .AbstractRootElementProvider
> > .readFrom(AbstractRootElementProvider.java:97)
> > at
> > com
> > .sun
> > .jersey
> > .spi.container.ContainerRequest.getEntity(ContainerRequest.java:391)
> > at
> > com
> > .sun
> > .jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider
> > $EntityInjectable.getValue(EntityParamDispatchProvider.java:81)
> > at
> > com
> > .sun
> > .jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider
> > $EntityParamInInvoker.getParams(EntityParamDispatchProvider.java:99)
> > at
> > com
> > .sun
> > .jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider
> > $VoidOutInvoker._dispatch(EntityParamDispatchProvider.java:120)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .model
> > .method
> > .dispatch
> > .ResourceJavaMethodDispatcher
> > .dispatch(ResourceJavaMethodDispatcher.java:67)
> > at
> > com
> > .sun
> > .jersey
> > .server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:154)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .uri
> > .rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .application
> > .WebApplicationImpl._handleRequest(WebApplicationImpl.java:543)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .application
> > .WebApplicationImpl.handleRequest(WebApplicationImpl.java:502)
> > at
> > com
> > .sun
> > .jersey
> > .server
> > .impl
> > .application
> > .WebApplicationImpl.handleRequest(WebApplicationImpl.java:493)
> > at
> > com
> > .sun
> > .jersey.spi.container.servlet.WebComponent.service(WebComponent.java:
> > 308)
> > at
> > com
> > .sun
> > .jersey
> > .spi
> > .container.servlet.ServletContainer.service(ServletContainer.java:314)
> > at
> > com
> > .sun
> > .jersey
> > .spi
> > .container.servlet.ServletContainer.service(ServletContainer.java:239)
> > at
> > org
> > .apache
> > .catalina
> > .core
> > .ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
> > 290)
> > at
> > org
> > .apache
> > .catalina
> > .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> > at
> > org
> > .apache
> > .catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
> > 228)
> > at
> > org
> > .apache
> > .catalina.core.StandardContextValve.invoke(StandardContextValve.java:
> > 175)
> > at
> > org
> > .apache
> > .catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
> > at
> > org
> > .apache
> > .catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
> > at
> > org
> > .apache
> > .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
> > 109)
> > at
> > org
> > .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
> > 212)
> > at
> > org
> > .apache.coyote.http11.Http11Processor.process(Http11Processor.java:
> > 844)
> > at org.apache.coyote.http11.Http11Protocol
> > $Http11ConnectionHandler.process(Http11Protocol.java:634)
> > at org.apache.tomcat.util.net.JIoEndpoint
> > $Worker.run(JIoEndpoint.java:445)
> > at java.lang.Thread.run(Thread.java:619)
> >
> > Can anyone help me ?
> >
> > -Sanju
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: dev-help_at_jersey.dev.java.net
> >
>

Windows Live™: Keep your life in sync. Check it out.
Hotmail® has ever-growing storage! Don’t worry about storage limits. Check it out.
_________________________________________________________________
Hotmail® goes with you.
http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009