users@jersey.java.net

[Jersey] Unmarshalling client response problems

From: Eugene Prokopiev <enp_at_itx.ru>
Date: Tue, 10 Feb 2015 21:26:28 +0400

Hi,

On running:

client.target("").path("http://localhost/person.xml").request().get(Person.class);

I see something like:

Exception in thread "main" javax.ws.rs.BadRequestException: HTTP 400 Bad Request
    at org.glassfish.jersey.message.internal.AbstractRootElementJaxbProvider.readFrom(AbstractRootElementJaxbProvider.java:124)
    ...
    at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:308)
    at ru.itx.proxyapp.Client.main(Client.java:10)
Caused by: javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://www.itx.ru/schemas/2014/02/messages", local:"Person").
Expected elements are <{}Person>
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:681)
    ...
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:163)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
    ...
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:243)
    at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:214)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:140)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:123)
    at org.glassfish.jersey.message.internal.XmlRootElementJaxbProvider.readFrom(XmlRootElementJaxbProvider.java:140)
    at org.glassfish.jersey.message.internal.AbstractRootElementJaxbProvider.readFrom(AbstractRootElementJaxbProvider.java:122)
    ... 18 more

File http://localhost/person.xml can be successfully unmarshalled with
Woodstox StAX implementation with
XMLInputFactory.IS_NAMESPACE_AWARE=false. Is it possible to use
Woodstox StAX implementation with Jersey client instead of SAXParser?

-- 
WBR,
Eugene Prokopiev