You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by José Luis Cetina <ma...@gmail.com> on 2014/02/24 20:05:32 UTC

JAX-RS JSON unexpected element

Hi, im doing my first rest service. Im having problem's with retrieving the
json data, when my method is called i get an:

WARNING: javax.xml.bind.UnmarshalException
 - with linked exception:
[com.sun.istack.SAXParseException2; columnNumber: 0; unexpected element
(uri:"", local:"id"). Expected elements are <{}conektaEvent>,<{}data>]
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)


Do im missing something, any advice?


Here is the json object that im trying to receive me in the post method:

{
  "id":"521154c132611f5bc0000029",
  "type":"charge.paid",
  "created_at":1376867521,
  "data":{
    "object":{
      "id":"521154c032611f5bc0000028",
      "object":"charge",
      "livemode":false,
      "created_at":1376867520,
      "status":"paid",
      "currency":"MXN",
      "description":"Autocinema Coyote - Eterno resplandor de una mente sin
recuerdos",
      "reference_id":"XXYYZZ-TEST1234",
      "failure_code":"",
      "failure_message":null,
      "amount":20000,
      "paid_at":1377021230,
      "fee":1160,
      payment_method":{
        "object":"bank_transfer_payment",
        "service_name":"Conekta",
        "service_number":"127589",
        "type":"banorte",
        "reference":"0007131"
      },
      "details":{
        "name":"Gustavo Delgado",
        "phone":5555555555,
        "email":"gustavo.delgado@gmail.com"
      }
    },
    "previous_attributes":{
      "status":"pending_payment",
      "paid_at":1377021230
    }
  }
}



Pojo:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement()
public class ConektaEvent implements Serializable{

    @XmlAttribute(name="id")
    private String id;
    @XmlAttribute(name="type")
    private String type;
    @XmlElement(name="created_at")
    private Timestamp createdAt;
    @XmlElement(name="data", type = ConektaData.class)
    private ConektaData data;

    public ConektaEvent() {
    }

    //getters and setters
}


I have a /WEB-INF/resources.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <Service id="json"
class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
        SkipJaxbChecks = true
        DropRootElement = true
        SupportUnwrapped = true
        SingleJaxbContext = true
    </Service>
</resources>



Im newbie in jax-rs any help will be appreciated.

Im using TomEE 1.6.0 JAX-RS

Re: JAX-RS JSON unexpected element

Posted by Romain Manni-Bucau <rm...@gmail.com>.
We dont rely on xsd, an easy patch/contribution if you want ;)
Le 25 févr. 2014 18:56, "José Luis Cetina" <ma...@gmail.com> a écrit :

> Ok.
>
> @Romain The Jacksonprovider is working good, but IntellijIdea tell me that
> pojo-deployment tag is not allowed here, this is my openejb-jar file:
>
> <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
>              xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1 ">
>     <pojo-deployment class-name="jaxrs-application">
>          <properties>
>             cxf.jaxrs.providers =
> com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
>         </properties>
>     </pojo-deployment>
> </openejb-jar>}
>
>
> Then i dont know how this is working
>
>
>
>
> 2014-02-24 15:02 GMT-06:00 Romain Manni-Bucau <rm...@gmail.com>:
>
> > maybe test @xmltransient
> > Romain Manni-Bucau
> > Twitter: @rmannibucau
> > Blog: http://rmannibucau.wordpress.com/
> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
> > Github: https://github.com/rmannibucau
> >
> >
> >
> > 2014-02-24 21:58 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> > > @Romain is something like @JsonIgnoreProperties in jettison?
> > >
> > >
> > > 2014-02-24 14:20 GMT-06:00 José Luis Cetina <ma...@gmail.com>:
> > >
> > >> Ok, i will try it.
> > >>
> > >>
> > >> 2014-02-24 14:18 GMT-06:00 Romain Manni-Bucau <rmannibucau@gmail.com
> >:
> > >>
> > >> yes it is coming with cxf in jaxrs and plus versions
> > >>> Romain Manni-Bucau
> > >>> Twitter: @rmannibucau
> > >>> Blog: http://rmannibucau.wordpress.com/
> > >>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> > >>> Github: https://github.com/rmannibucau
> > >>>
> > >>>
> > >>>
> > >>> 2014-02-24 21:17 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> > >>> > @Romain, is jettison bundled with TomEE?
> > >>> >
> > >>> >
> > >>> > 2014-02-24 14:14 GMT-06:00 John D. Ament <jo...@gmail.com>:
> > >>> >
> > >>> >> Actually I was curious for the code since it seems like he's
> > >>> >> referencing XML in the error, but sending JSON.
> > >>> >>
> > >>> >> On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
> > >>> >> <rm...@gmail.com> wrote:
> > >>> >> > cause default provider is using jaxb model so it needs a
> wrapper.
> > >>> >> > Jackson doesnt. (see jettison)
> > >>> >> >
> > >>> >> > Side note: you can put this conf in openejb-jar.xml
> > >>> >> > Romain Manni-Bucau
> > >>> >> > Twitter: @rmannibucau
> > >>> >> > Blog: http://rmannibucau.wordpress.com/
> > >>> >> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
> > >>> >> > Github: https://github.com/rmannibucau
> > >>> >> >
> > >>> >> >
> > >>> >> >
> > >>> >> > 2014-02-24 21:00 GMT+01:00 José Luis Cetina <
> maxtorzito@gmail.com
> > >:
> > >>> >> >> Hi @John, the problem is in the @XmlRootElement, Jackson
> provider
> > >>> >> doesn't
> > >>> >> >> need it, then i just add Jackson as a provider and everything
> > works.
> > >>> >> >>
> > >>> >> >>
> > >>> >> >> But i dont understand why with the default provider this
> doesn't
> > >>> work.
> > >>> >> >>
> > >>> >> >>
> > >>> >> >> I add the jackson dependecy and
> > >>> >> >> the
> > >>> >>
> > >>>
> >
> -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
> > >>> >> >> property.  :)
> > >>> >> >>
> > >>> >> >>
> > >>> >> >> 2014-02-24 13:47 GMT-06:00 John D. Ament <
> john.d.ament@gmail.com
> > >:
> > >>> >> >>
> > >>> >> >>> Can you post the code for your resource?
> > >>> >> >>>
> > >>> >> >>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <
> > >>> >> maxtorzito@gmail.com>
> > >>> >> >>> wrote:
> > >>> >> >>> > Hi, im doing my first rest service. Im having problem's with
> > >>> >> retrieving
> > >>> >> >>> the
> > >>> >> >>> > json data, when my method is called i get an:
> > >>> >> >>> >
> > >>> >> >>> > WARNING: javax.xml.bind.UnmarshalException
> > >>> >> >>> >  - with linked exception:
> > >>> >> >>> > [com.sun.istack.SAXParseException2; columnNumber: 0;
> > unexpected
> > >>> >> element
> > >>> >> >>> > (uri:"", local:"id"). Expected elements are
> > >>> >> <{}conektaEvent>,<{}data>]
> > >>> >> >>> > at
> > >>> >> >>> >
> > >>> >> >>>
> > >>> >>
> > >>>
> >
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
> > >>> >> >>> >
> > >>> >> >>> >
> > >>> >> >>> > Do im missing something, any advice?
> > >>> >> >>> >
> > >>> >> >>> >
> > >>> >> >>> > Here is the json object that im trying to receive me in the
> > post
> > >>> >> method:
> > >>> >> >>> >
> > >>> >> >>> > {
> > >>> >> >>> >   "id":"521154c132611f5bc0000029",
> > >>> >> >>> >   "type":"charge.paid",
> > >>> >> >>> >   "created_at":1376867521,
> > >>> >> >>> >   "data":{
> > >>> >> >>> >     "object":{
> > >>> >> >>> >       "id":"521154c032611f5bc0000028",
> > >>> >> >>> >       "object":"charge",
> > >>> >> >>> >       "livemode":false,
> > >>> >> >>> >       "created_at":1376867520,
> > >>> >> >>> >       "status":"paid",
> > >>> >> >>> >       "currency":"MXN",
> > >>> >> >>> >       "description":"Autocinema Coyote - Eterno resplandor
> de
> > una
> > >>> >> mente
> > >>> >> >>> sin
> > >>> >> >>> > recuerdos",
> > >>> >> >>> >       "reference_id":"XXYYZZ-TEST1234",
> > >>> >> >>> >       "failure_code":"",
> > >>> >> >>> >       "failure_message":null,
> > >>> >> >>> >       "amount":20000,
> > >>> >> >>> >       "paid_at":1377021230,
> > >>> >> >>> >       "fee":1160,
> > >>> >> >>> >       payment_method":{
> > >>> >> >>> >         "object":"bank_transfer_payment",
> > >>> >> >>> >         "service_name":"Conekta",
> > >>> >> >>> >         "service_number":"127589",
> > >>> >> >>> >         "type":"banorte",
> > >>> >> >>> >         "reference":"0007131"
> > >>> >> >>> >       },
> > >>> >> >>> >       "details":{
> > >>> >> >>> >         "name":"Gustavo Delgado",
> > >>> >> >>> >         "phone":5555555555,
> > >>> >> >>> >         "email":"gustavo.delgado@gmail.com"
> > >>> >> >>> >       }
> > >>> >> >>> >     },
> > >>> >> >>> >     "previous_attributes":{
> > >>> >> >>> >       "status":"pending_payment",
> > >>> >> >>> >       "paid_at":1377021230
> > >>> >> >>> >     }
> > >>> >> >>> >   }
> > >>> >> >>> > }
> > >>> >> >>> >
> > >>> >> >>> >
> > >>> >> >>> >
> > >>> >> >>> > Pojo:
> > >>> >> >>> >
> > >>> >> >>> > @XmlAccessorType(XmlAccessType.FIELD)
> > >>> >> >>> > @XmlRootElement()
> > >>> >> >>> > public class ConektaEvent implements Serializable{
> > >>> >> >>> >
> > >>> >> >>> >     @XmlAttribute(name="id")
> > >>> >> >>> >     private String id;
> > >>> >> >>> >     @XmlAttribute(name="type")
> > >>> >> >>> >     private String type;
> > >>> >> >>> >     @XmlElement(name="created_at")
> > >>> >> >>> >     private Timestamp createdAt;
> > >>> >> >>> >     @XmlElement(name="data", type = ConektaData.class)
> > >>> >> >>> >     private ConektaData data;
> > >>> >> >>> >
> > >>> >> >>> >     public ConektaEvent() {
> > >>> >> >>> >     }
> > >>> >> >>> >
> > >>> >> >>> >     //getters and setters
> > >>> >> >>> > }
> > >>> >> >>> >
> > >>> >> >>> >
> > >>> >> >>> > I have a /WEB-INF/resources.xml
> > >>> >> >>> >
> > >>> >> >>> > <?xml version="1.0" encoding="UTF-8"?>
> > >>> >> >>> > <resources>
> > >>> >> >>> >     <Service id="json"
> > >>> >> >>> >
> class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
> > >>> >> >>> >         SkipJaxbChecks = true
> > >>> >> >>> >         DropRootElement = true
> > >>> >> >>> >         SupportUnwrapped = true
> > >>> >> >>> >         SingleJaxbContext = true
> > >>> >> >>> >     </Service>
> > >>> >> >>> > </resources>
> > >>> >> >>> >
> > >>> >> >>> >
> > >>> >> >>> >
> > >>> >> >>> > Im newbie in jax-rs any help will be appreciated.
> > >>> >> >>> >
> > >>> >> >>> > Im using TomEE 1.6.0 JAX-RS
> > >>> >> >>>
> > >>> >> >>
> > >>> >> >>
> > >>> >> >>
> > >>> >> >> --
> > >>> >> >>
> > -------------------------------------------------------------------
> > >>> >> >> *José Luis Cetina*
> > >>> >> >>
> > -------------------------------------------------------------------
> > >>> >>
> > >>> >
> > >>> >
> > >>> >
> > >>> > --
> > >>> > -------------------------------------------------------------------
> > >>> > *José Luis Cetina*
> > >>> > -------------------------------------------------------------------
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >> -------------------------------------------------------------------
> > >> *José Luis Cetina*
> > >> -------------------------------------------------------------------
> > >>
> > >
> > >
> > >
> > > --
> > > -------------------------------------------------------------------
> > > *José Luis Cetina*
> > > -------------------------------------------------------------------
> >
>
>
>
> --
> -------------------------------------------------------------------
> *José Luis Cetina*
> -------------------------------------------------------------------
>

Re: JAX-RS JSON unexpected element

Posted by José Luis Cetina <ma...@gmail.com>.
Ok.

@Romain The Jacksonprovider is working good, but IntellijIdea tell me that
pojo-deployment tag is not allowed here, this is my openejb-jar file:

<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1 ">
    <pojo-deployment class-name="jaxrs-application">
         <properties>
            cxf.jaxrs.providers =
com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
        </properties>
    </pojo-deployment>
</openejb-jar>}


Then i dont know how this is working




2014-02-24 15:02 GMT-06:00 Romain Manni-Bucau <rm...@gmail.com>:

> maybe test @xmltransient
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-02-24 21:58 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> > @Romain is something like @JsonIgnoreProperties in jettison?
> >
> >
> > 2014-02-24 14:20 GMT-06:00 José Luis Cetina <ma...@gmail.com>:
> >
> >> Ok, i will try it.
> >>
> >>
> >> 2014-02-24 14:18 GMT-06:00 Romain Manni-Bucau <rm...@gmail.com>:
> >>
> >> yes it is coming with cxf in jaxrs and plus versions
> >>> Romain Manni-Bucau
> >>> Twitter: @rmannibucau
> >>> Blog: http://rmannibucau.wordpress.com/
> >>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >>> Github: https://github.com/rmannibucau
> >>>
> >>>
> >>>
> >>> 2014-02-24 21:17 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> >>> > @Romain, is jettison bundled with TomEE?
> >>> >
> >>> >
> >>> > 2014-02-24 14:14 GMT-06:00 John D. Ament <jo...@gmail.com>:
> >>> >
> >>> >> Actually I was curious for the code since it seems like he's
> >>> >> referencing XML in the error, but sending JSON.
> >>> >>
> >>> >> On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
> >>> >> <rm...@gmail.com> wrote:
> >>> >> > cause default provider is using jaxb model so it needs a wrapper.
> >>> >> > Jackson doesnt. (see jettison)
> >>> >> >
> >>> >> > Side note: you can put this conf in openejb-jar.xml
> >>> >> > Romain Manni-Bucau
> >>> >> > Twitter: @rmannibucau
> >>> >> > Blog: http://rmannibucau.wordpress.com/
> >>> >> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >>> >> > Github: https://github.com/rmannibucau
> >>> >> >
> >>> >> >
> >>> >> >
> >>> >> > 2014-02-24 21:00 GMT+01:00 José Luis Cetina <maxtorzito@gmail.com
> >:
> >>> >> >> Hi @John, the problem is in the @XmlRootElement, Jackson provider
> >>> >> doesn't
> >>> >> >> need it, then i just add Jackson as a provider and everything
> works.
> >>> >> >>
> >>> >> >>
> >>> >> >> But i dont understand why with the default provider this doesn't
> >>> work.
> >>> >> >>
> >>> >> >>
> >>> >> >> I add the jackson dependecy and
> >>> >> >> the
> >>> >>
> >>>
> -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
> >>> >> >> property.  :)
> >>> >> >>
> >>> >> >>
> >>> >> >> 2014-02-24 13:47 GMT-06:00 John D. Ament <john.d.ament@gmail.com
> >:
> >>> >> >>
> >>> >> >>> Can you post the code for your resource?
> >>> >> >>>
> >>> >> >>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <
> >>> >> maxtorzito@gmail.com>
> >>> >> >>> wrote:
> >>> >> >>> > Hi, im doing my first rest service. Im having problem's with
> >>> >> retrieving
> >>> >> >>> the
> >>> >> >>> > json data, when my method is called i get an:
> >>> >> >>> >
> >>> >> >>> > WARNING: javax.xml.bind.UnmarshalException
> >>> >> >>> >  - with linked exception:
> >>> >> >>> > [com.sun.istack.SAXParseException2; columnNumber: 0;
> unexpected
> >>> >> element
> >>> >> >>> > (uri:"", local:"id"). Expected elements are
> >>> >> <{}conektaEvent>,<{}data>]
> >>> >> >>> > at
> >>> >> >>> >
> >>> >> >>>
> >>> >>
> >>>
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
> >>> >> >>> >
> >>> >> >>> >
> >>> >> >>> > Do im missing something, any advice?
> >>> >> >>> >
> >>> >> >>> >
> >>> >> >>> > Here is the json object that im trying to receive me in the
> post
> >>> >> method:
> >>> >> >>> >
> >>> >> >>> > {
> >>> >> >>> >   "id":"521154c132611f5bc0000029",
> >>> >> >>> >   "type":"charge.paid",
> >>> >> >>> >   "created_at":1376867521,
> >>> >> >>> >   "data":{
> >>> >> >>> >     "object":{
> >>> >> >>> >       "id":"521154c032611f5bc0000028",
> >>> >> >>> >       "object":"charge",
> >>> >> >>> >       "livemode":false,
> >>> >> >>> >       "created_at":1376867520,
> >>> >> >>> >       "status":"paid",
> >>> >> >>> >       "currency":"MXN",
> >>> >> >>> >       "description":"Autocinema Coyote - Eterno resplandor de
> una
> >>> >> mente
> >>> >> >>> sin
> >>> >> >>> > recuerdos",
> >>> >> >>> >       "reference_id":"XXYYZZ-TEST1234",
> >>> >> >>> >       "failure_code":"",
> >>> >> >>> >       "failure_message":null,
> >>> >> >>> >       "amount":20000,
> >>> >> >>> >       "paid_at":1377021230,
> >>> >> >>> >       "fee":1160,
> >>> >> >>> >       payment_method":{
> >>> >> >>> >         "object":"bank_transfer_payment",
> >>> >> >>> >         "service_name":"Conekta",
> >>> >> >>> >         "service_number":"127589",
> >>> >> >>> >         "type":"banorte",
> >>> >> >>> >         "reference":"0007131"
> >>> >> >>> >       },
> >>> >> >>> >       "details":{
> >>> >> >>> >         "name":"Gustavo Delgado",
> >>> >> >>> >         "phone":5555555555,
> >>> >> >>> >         "email":"gustavo.delgado@gmail.com"
> >>> >> >>> >       }
> >>> >> >>> >     },
> >>> >> >>> >     "previous_attributes":{
> >>> >> >>> >       "status":"pending_payment",
> >>> >> >>> >       "paid_at":1377021230
> >>> >> >>> >     }
> >>> >> >>> >   }
> >>> >> >>> > }
> >>> >> >>> >
> >>> >> >>> >
> >>> >> >>> >
> >>> >> >>> > Pojo:
> >>> >> >>> >
> >>> >> >>> > @XmlAccessorType(XmlAccessType.FIELD)
> >>> >> >>> > @XmlRootElement()
> >>> >> >>> > public class ConektaEvent implements Serializable{
> >>> >> >>> >
> >>> >> >>> >     @XmlAttribute(name="id")
> >>> >> >>> >     private String id;
> >>> >> >>> >     @XmlAttribute(name="type")
> >>> >> >>> >     private String type;
> >>> >> >>> >     @XmlElement(name="created_at")
> >>> >> >>> >     private Timestamp createdAt;
> >>> >> >>> >     @XmlElement(name="data", type = ConektaData.class)
> >>> >> >>> >     private ConektaData data;
> >>> >> >>> >
> >>> >> >>> >     public ConektaEvent() {
> >>> >> >>> >     }
> >>> >> >>> >
> >>> >> >>> >     //getters and setters
> >>> >> >>> > }
> >>> >> >>> >
> >>> >> >>> >
> >>> >> >>> > I have a /WEB-INF/resources.xml
> >>> >> >>> >
> >>> >> >>> > <?xml version="1.0" encoding="UTF-8"?>
> >>> >> >>> > <resources>
> >>> >> >>> >     <Service id="json"
> >>> >> >>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
> >>> >> >>> >         SkipJaxbChecks = true
> >>> >> >>> >         DropRootElement = true
> >>> >> >>> >         SupportUnwrapped = true
> >>> >> >>> >         SingleJaxbContext = true
> >>> >> >>> >     </Service>
> >>> >> >>> > </resources>
> >>> >> >>> >
> >>> >> >>> >
> >>> >> >>> >
> >>> >> >>> > Im newbie in jax-rs any help will be appreciated.
> >>> >> >>> >
> >>> >> >>> > Im using TomEE 1.6.0 JAX-RS
> >>> >> >>>
> >>> >> >>
> >>> >> >>
> >>> >> >>
> >>> >> >> --
> >>> >> >>
> -------------------------------------------------------------------
> >>> >> >> *José Luis Cetina*
> >>> >> >>
> -------------------------------------------------------------------
> >>> >>
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > -------------------------------------------------------------------
> >>> > *José Luis Cetina*
> >>> > -------------------------------------------------------------------
> >>>
> >>
> >>
> >>
> >> --
> >> -------------------------------------------------------------------
> >> *José Luis Cetina*
> >> -------------------------------------------------------------------
> >>
> >
> >
> >
> > --
> > -------------------------------------------------------------------
> > *José Luis Cetina*
> > -------------------------------------------------------------------
>



-- 
-------------------------------------------------------------------
*José Luis Cetina*
-------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by Romain Manni-Bucau <rm...@gmail.com>.
maybe test @xmltransient
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-02-24 21:58 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> @Romain is something like @JsonIgnoreProperties in jettison?
>
>
> 2014-02-24 14:20 GMT-06:00 José Luis Cetina <ma...@gmail.com>:
>
>> Ok, i will try it.
>>
>>
>> 2014-02-24 14:18 GMT-06:00 Romain Manni-Bucau <rm...@gmail.com>:
>>
>> yes it is coming with cxf in jaxrs and plus versions
>>> Romain Manni-Bucau
>>> Twitter: @rmannibucau
>>> Blog: http://rmannibucau.wordpress.com/
>>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>>> Github: https://github.com/rmannibucau
>>>
>>>
>>>
>>> 2014-02-24 21:17 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
>>> > @Romain, is jettison bundled with TomEE?
>>> >
>>> >
>>> > 2014-02-24 14:14 GMT-06:00 John D. Ament <jo...@gmail.com>:
>>> >
>>> >> Actually I was curious for the code since it seems like he's
>>> >> referencing XML in the error, but sending JSON.
>>> >>
>>> >> On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
>>> >> <rm...@gmail.com> wrote:
>>> >> > cause default provider is using jaxb model so it needs a wrapper.
>>> >> > Jackson doesnt. (see jettison)
>>> >> >
>>> >> > Side note: you can put this conf in openejb-jar.xml
>>> >> > Romain Manni-Bucau
>>> >> > Twitter: @rmannibucau
>>> >> > Blog: http://rmannibucau.wordpress.com/
>>> >> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
>>> >> > Github: https://github.com/rmannibucau
>>> >> >
>>> >> >
>>> >> >
>>> >> > 2014-02-24 21:00 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
>>> >> >> Hi @John, the problem is in the @XmlRootElement, Jackson provider
>>> >> doesn't
>>> >> >> need it, then i just add Jackson as a provider and everything works.
>>> >> >>
>>> >> >>
>>> >> >> But i dont understand why with the default provider this doesn't
>>> work.
>>> >> >>
>>> >> >>
>>> >> >> I add the jackson dependecy and
>>> >> >> the
>>> >>
>>> -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
>>> >> >> property.  :)
>>> >> >>
>>> >> >>
>>> >> >> 2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:
>>> >> >>
>>> >> >>> Can you post the code for your resource?
>>> >> >>>
>>> >> >>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <
>>> >> maxtorzito@gmail.com>
>>> >> >>> wrote:
>>> >> >>> > Hi, im doing my first rest service. Im having problem's with
>>> >> retrieving
>>> >> >>> the
>>> >> >>> > json data, when my method is called i get an:
>>> >> >>> >
>>> >> >>> > WARNING: javax.xml.bind.UnmarshalException
>>> >> >>> >  - with linked exception:
>>> >> >>> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected
>>> >> element
>>> >> >>> > (uri:"", local:"id"). Expected elements are
>>> >> <{}conektaEvent>,<{}data>]
>>> >> >>> > at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > Do im missing something, any advice?
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > Here is the json object that im trying to receive me in the post
>>> >> method:
>>> >> >>> >
>>> >> >>> > {
>>> >> >>> >   "id":"521154c132611f5bc0000029",
>>> >> >>> >   "type":"charge.paid",
>>> >> >>> >   "created_at":1376867521,
>>> >> >>> >   "data":{
>>> >> >>> >     "object":{
>>> >> >>> >       "id":"521154c032611f5bc0000028",
>>> >> >>> >       "object":"charge",
>>> >> >>> >       "livemode":false,
>>> >> >>> >       "created_at":1376867520,
>>> >> >>> >       "status":"paid",
>>> >> >>> >       "currency":"MXN",
>>> >> >>> >       "description":"Autocinema Coyote - Eterno resplandor de una
>>> >> mente
>>> >> >>> sin
>>> >> >>> > recuerdos",
>>> >> >>> >       "reference_id":"XXYYZZ-TEST1234",
>>> >> >>> >       "failure_code":"",
>>> >> >>> >       "failure_message":null,
>>> >> >>> >       "amount":20000,
>>> >> >>> >       "paid_at":1377021230,
>>> >> >>> >       "fee":1160,
>>> >> >>> >       payment_method":{
>>> >> >>> >         "object":"bank_transfer_payment",
>>> >> >>> >         "service_name":"Conekta",
>>> >> >>> >         "service_number":"127589",
>>> >> >>> >         "type":"banorte",
>>> >> >>> >         "reference":"0007131"
>>> >> >>> >       },
>>> >> >>> >       "details":{
>>> >> >>> >         "name":"Gustavo Delgado",
>>> >> >>> >         "phone":5555555555,
>>> >> >>> >         "email":"gustavo.delgado@gmail.com"
>>> >> >>> >       }
>>> >> >>> >     },
>>> >> >>> >     "previous_attributes":{
>>> >> >>> >       "status":"pending_payment",
>>> >> >>> >       "paid_at":1377021230
>>> >> >>> >     }
>>> >> >>> >   }
>>> >> >>> > }
>>> >> >>> >
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > Pojo:
>>> >> >>> >
>>> >> >>> > @XmlAccessorType(XmlAccessType.FIELD)
>>> >> >>> > @XmlRootElement()
>>> >> >>> > public class ConektaEvent implements Serializable{
>>> >> >>> >
>>> >> >>> >     @XmlAttribute(name="id")
>>> >> >>> >     private String id;
>>> >> >>> >     @XmlAttribute(name="type")
>>> >> >>> >     private String type;
>>> >> >>> >     @XmlElement(name="created_at")
>>> >> >>> >     private Timestamp createdAt;
>>> >> >>> >     @XmlElement(name="data", type = ConektaData.class)
>>> >> >>> >     private ConektaData data;
>>> >> >>> >
>>> >> >>> >     public ConektaEvent() {
>>> >> >>> >     }
>>> >> >>> >
>>> >> >>> >     //getters and setters
>>> >> >>> > }
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > I have a /WEB-INF/resources.xml
>>> >> >>> >
>>> >> >>> > <?xml version="1.0" encoding="UTF-8"?>
>>> >> >>> > <resources>
>>> >> >>> >     <Service id="json"
>>> >> >>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>> >> >>> >         SkipJaxbChecks = true
>>> >> >>> >         DropRootElement = true
>>> >> >>> >         SupportUnwrapped = true
>>> >> >>> >         SingleJaxbContext = true
>>> >> >>> >     </Service>
>>> >> >>> > </resources>
>>> >> >>> >
>>> >> >>> >
>>> >> >>> >
>>> >> >>> > Im newbie in jax-rs any help will be appreciated.
>>> >> >>> >
>>> >> >>> > Im using TomEE 1.6.0 JAX-RS
>>> >> >>>
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> --
>>> >> >> -------------------------------------------------------------------
>>> >> >> *José Luis Cetina*
>>> >> >> -------------------------------------------------------------------
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > -------------------------------------------------------------------
>>> > *José Luis Cetina*
>>> > -------------------------------------------------------------------
>>>
>>
>>
>>
>> --
>> -------------------------------------------------------------------
>> *José Luis Cetina*
>> -------------------------------------------------------------------
>>
>
>
>
> --
> -------------------------------------------------------------------
> *José Luis Cetina*
> -------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by José Luis Cetina <ma...@gmail.com>.
@Romain is something like @JsonIgnoreProperties in jettison?


2014-02-24 14:20 GMT-06:00 José Luis Cetina <ma...@gmail.com>:

> Ok, i will try it.
>
>
> 2014-02-24 14:18 GMT-06:00 Romain Manni-Bucau <rm...@gmail.com>:
>
> yes it is coming with cxf in jaxrs and plus versions
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>>
>> 2014-02-24 21:17 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
>> > @Romain, is jettison bundled with TomEE?
>> >
>> >
>> > 2014-02-24 14:14 GMT-06:00 John D. Ament <jo...@gmail.com>:
>> >
>> >> Actually I was curious for the code since it seems like he's
>> >> referencing XML in the error, but sending JSON.
>> >>
>> >> On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
>> >> <rm...@gmail.com> wrote:
>> >> > cause default provider is using jaxb model so it needs a wrapper.
>> >> > Jackson doesnt. (see jettison)
>> >> >
>> >> > Side note: you can put this conf in openejb-jar.xml
>> >> > Romain Manni-Bucau
>> >> > Twitter: @rmannibucau
>> >> > Blog: http://rmannibucau.wordpress.com/
>> >> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> >> > Github: https://github.com/rmannibucau
>> >> >
>> >> >
>> >> >
>> >> > 2014-02-24 21:00 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
>> >> >> Hi @John, the problem is in the @XmlRootElement, Jackson provider
>> >> doesn't
>> >> >> need it, then i just add Jackson as a provider and everything works.
>> >> >>
>> >> >>
>> >> >> But i dont understand why with the default provider this doesn't
>> work.
>> >> >>
>> >> >>
>> >> >> I add the jackson dependecy and
>> >> >> the
>> >>
>> -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
>> >> >> property.  :)
>> >> >>
>> >> >>
>> >> >> 2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:
>> >> >>
>> >> >>> Can you post the code for your resource?
>> >> >>>
>> >> >>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <
>> >> maxtorzito@gmail.com>
>> >> >>> wrote:
>> >> >>> > Hi, im doing my first rest service. Im having problem's with
>> >> retrieving
>> >> >>> the
>> >> >>> > json data, when my method is called i get an:
>> >> >>> >
>> >> >>> > WARNING: javax.xml.bind.UnmarshalException
>> >> >>> >  - with linked exception:
>> >> >>> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected
>> >> element
>> >> >>> > (uri:"", local:"id"). Expected elements are
>> >> <{}conektaEvent>,<{}data>]
>> >> >>> > at
>> >> >>> >
>> >> >>>
>> >>
>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
>> >> >>> >
>> >> >>> >
>> >> >>> > Do im missing something, any advice?
>> >> >>> >
>> >> >>> >
>> >> >>> > Here is the json object that im trying to receive me in the post
>> >> method:
>> >> >>> >
>> >> >>> > {
>> >> >>> >   "id":"521154c132611f5bc0000029",
>> >> >>> >   "type":"charge.paid",
>> >> >>> >   "created_at":1376867521,
>> >> >>> >   "data":{
>> >> >>> >     "object":{
>> >> >>> >       "id":"521154c032611f5bc0000028",
>> >> >>> >       "object":"charge",
>> >> >>> >       "livemode":false,
>> >> >>> >       "created_at":1376867520,
>> >> >>> >       "status":"paid",
>> >> >>> >       "currency":"MXN",
>> >> >>> >       "description":"Autocinema Coyote - Eterno resplandor de una
>> >> mente
>> >> >>> sin
>> >> >>> > recuerdos",
>> >> >>> >       "reference_id":"XXYYZZ-TEST1234",
>> >> >>> >       "failure_code":"",
>> >> >>> >       "failure_message":null,
>> >> >>> >       "amount":20000,
>> >> >>> >       "paid_at":1377021230,
>> >> >>> >       "fee":1160,
>> >> >>> >       payment_method":{
>> >> >>> >         "object":"bank_transfer_payment",
>> >> >>> >         "service_name":"Conekta",
>> >> >>> >         "service_number":"127589",
>> >> >>> >         "type":"banorte",
>> >> >>> >         "reference":"0007131"
>> >> >>> >       },
>> >> >>> >       "details":{
>> >> >>> >         "name":"Gustavo Delgado",
>> >> >>> >         "phone":5555555555,
>> >> >>> >         "email":"gustavo.delgado@gmail.com"
>> >> >>> >       }
>> >> >>> >     },
>> >> >>> >     "previous_attributes":{
>> >> >>> >       "status":"pending_payment",
>> >> >>> >       "paid_at":1377021230
>> >> >>> >     }
>> >> >>> >   }
>> >> >>> > }
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>> > Pojo:
>> >> >>> >
>> >> >>> > @XmlAccessorType(XmlAccessType.FIELD)
>> >> >>> > @XmlRootElement()
>> >> >>> > public class ConektaEvent implements Serializable{
>> >> >>> >
>> >> >>> >     @XmlAttribute(name="id")
>> >> >>> >     private String id;
>> >> >>> >     @XmlAttribute(name="type")
>> >> >>> >     private String type;
>> >> >>> >     @XmlElement(name="created_at")
>> >> >>> >     private Timestamp createdAt;
>> >> >>> >     @XmlElement(name="data", type = ConektaData.class)
>> >> >>> >     private ConektaData data;
>> >> >>> >
>> >> >>> >     public ConektaEvent() {
>> >> >>> >     }
>> >> >>> >
>> >> >>> >     //getters and setters
>> >> >>> > }
>> >> >>> >
>> >> >>> >
>> >> >>> > I have a /WEB-INF/resources.xml
>> >> >>> >
>> >> >>> > <?xml version="1.0" encoding="UTF-8"?>
>> >> >>> > <resources>
>> >> >>> >     <Service id="json"
>> >> >>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>> >> >>> >         SkipJaxbChecks = true
>> >> >>> >         DropRootElement = true
>> >> >>> >         SupportUnwrapped = true
>> >> >>> >         SingleJaxbContext = true
>> >> >>> >     </Service>
>> >> >>> > </resources>
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>> > Im newbie in jax-rs any help will be appreciated.
>> >> >>> >
>> >> >>> > Im using TomEE 1.6.0 JAX-RS
>> >> >>>
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> -------------------------------------------------------------------
>> >> >> *José Luis Cetina*
>> >> >> -------------------------------------------------------------------
>> >>
>> >
>> >
>> >
>> > --
>> > -------------------------------------------------------------------
>> > *José Luis Cetina*
>> > -------------------------------------------------------------------
>>
>
>
>
> --
> -------------------------------------------------------------------
> *José Luis Cetina*
> -------------------------------------------------------------------
>



-- 
-------------------------------------------------------------------
*José Luis Cetina*
-------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by José Luis Cetina <ma...@gmail.com>.
Ok, i will try it.


2014-02-24 14:18 GMT-06:00 Romain Manni-Bucau <rm...@gmail.com>:

> yes it is coming with cxf in jaxrs and plus versions
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-02-24 21:17 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> > @Romain, is jettison bundled with TomEE?
> >
> >
> > 2014-02-24 14:14 GMT-06:00 John D. Ament <jo...@gmail.com>:
> >
> >> Actually I was curious for the code since it seems like he's
> >> referencing XML in the error, but sending JSON.
> >>
> >> On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
> >> <rm...@gmail.com> wrote:
> >> > cause default provider is using jaxb model so it needs a wrapper.
> >> > Jackson doesnt. (see jettison)
> >> >
> >> > Side note: you can put this conf in openejb-jar.xml
> >> > Romain Manni-Bucau
> >> > Twitter: @rmannibucau
> >> > Blog: http://rmannibucau.wordpress.com/
> >> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> > Github: https://github.com/rmannibucau
> >> >
> >> >
> >> >
> >> > 2014-02-24 21:00 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> >> >> Hi @John, the problem is in the @XmlRootElement, Jackson provider
> >> doesn't
> >> >> need it, then i just add Jackson as a provider and everything works.
> >> >>
> >> >>
> >> >> But i dont understand why with the default provider this doesn't
> work.
> >> >>
> >> >>
> >> >> I add the jackson dependecy and
> >> >> the
> >>
> -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
> >> >> property.  :)
> >> >>
> >> >>
> >> >> 2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:
> >> >>
> >> >>> Can you post the code for your resource?
> >> >>>
> >> >>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <
> >> maxtorzito@gmail.com>
> >> >>> wrote:
> >> >>> > Hi, im doing my first rest service. Im having problem's with
> >> retrieving
> >> >>> the
> >> >>> > json data, when my method is called i get an:
> >> >>> >
> >> >>> > WARNING: javax.xml.bind.UnmarshalException
> >> >>> >  - with linked exception:
> >> >>> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected
> >> element
> >> >>> > (uri:"", local:"id"). Expected elements are
> >> <{}conektaEvent>,<{}data>]
> >> >>> > at
> >> >>> >
> >> >>>
> >>
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
> >> >>> >
> >> >>> >
> >> >>> > Do im missing something, any advice?
> >> >>> >
> >> >>> >
> >> >>> > Here is the json object that im trying to receive me in the post
> >> method:
> >> >>> >
> >> >>> > {
> >> >>> >   "id":"521154c132611f5bc0000029",
> >> >>> >   "type":"charge.paid",
> >> >>> >   "created_at":1376867521,
> >> >>> >   "data":{
> >> >>> >     "object":{
> >> >>> >       "id":"521154c032611f5bc0000028",
> >> >>> >       "object":"charge",
> >> >>> >       "livemode":false,
> >> >>> >       "created_at":1376867520,
> >> >>> >       "status":"paid",
> >> >>> >       "currency":"MXN",
> >> >>> >       "description":"Autocinema Coyote - Eterno resplandor de una
> >> mente
> >> >>> sin
> >> >>> > recuerdos",
> >> >>> >       "reference_id":"XXYYZZ-TEST1234",
> >> >>> >       "failure_code":"",
> >> >>> >       "failure_message":null,
> >> >>> >       "amount":20000,
> >> >>> >       "paid_at":1377021230,
> >> >>> >       "fee":1160,
> >> >>> >       payment_method":{
> >> >>> >         "object":"bank_transfer_payment",
> >> >>> >         "service_name":"Conekta",
> >> >>> >         "service_number":"127589",
> >> >>> >         "type":"banorte",
> >> >>> >         "reference":"0007131"
> >> >>> >       },
> >> >>> >       "details":{
> >> >>> >         "name":"Gustavo Delgado",
> >> >>> >         "phone":5555555555,
> >> >>> >         "email":"gustavo.delgado@gmail.com"
> >> >>> >       }
> >> >>> >     },
> >> >>> >     "previous_attributes":{
> >> >>> >       "status":"pending_payment",
> >> >>> >       "paid_at":1377021230
> >> >>> >     }
> >> >>> >   }
> >> >>> > }
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > Pojo:
> >> >>> >
> >> >>> > @XmlAccessorType(XmlAccessType.FIELD)
> >> >>> > @XmlRootElement()
> >> >>> > public class ConektaEvent implements Serializable{
> >> >>> >
> >> >>> >     @XmlAttribute(name="id")
> >> >>> >     private String id;
> >> >>> >     @XmlAttribute(name="type")
> >> >>> >     private String type;
> >> >>> >     @XmlElement(name="created_at")
> >> >>> >     private Timestamp createdAt;
> >> >>> >     @XmlElement(name="data", type = ConektaData.class)
> >> >>> >     private ConektaData data;
> >> >>> >
> >> >>> >     public ConektaEvent() {
> >> >>> >     }
> >> >>> >
> >> >>> >     //getters and setters
> >> >>> > }
> >> >>> >
> >> >>> >
> >> >>> > I have a /WEB-INF/resources.xml
> >> >>> >
> >> >>> > <?xml version="1.0" encoding="UTF-8"?>
> >> >>> > <resources>
> >> >>> >     <Service id="json"
> >> >>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
> >> >>> >         SkipJaxbChecks = true
> >> >>> >         DropRootElement = true
> >> >>> >         SupportUnwrapped = true
> >> >>> >         SingleJaxbContext = true
> >> >>> >     </Service>
> >> >>> > </resources>
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > Im newbie in jax-rs any help will be appreciated.
> >> >>> >
> >> >>> > Im using TomEE 1.6.0 JAX-RS
> >> >>>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> -------------------------------------------------------------------
> >> >> *José Luis Cetina*
> >> >> -------------------------------------------------------------------
> >>
> >
> >
> >
> > --
> > -------------------------------------------------------------------
> > *José Luis Cetina*
> > -------------------------------------------------------------------
>



-- 
-------------------------------------------------------------------
*José Luis Cetina*
-------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by Romain Manni-Bucau <rm...@gmail.com>.
yes it is coming with cxf in jaxrs and plus versions
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-02-24 21:17 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> @Romain, is jettison bundled with TomEE?
>
>
> 2014-02-24 14:14 GMT-06:00 John D. Ament <jo...@gmail.com>:
>
>> Actually I was curious for the code since it seems like he's
>> referencing XML in the error, but sending JSON.
>>
>> On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
>> <rm...@gmail.com> wrote:
>> > cause default provider is using jaxb model so it needs a wrapper.
>> > Jackson doesnt. (see jettison)
>> >
>> > Side note: you can put this conf in openejb-jar.xml
>> > Romain Manni-Bucau
>> > Twitter: @rmannibucau
>> > Blog: http://rmannibucau.wordpress.com/
>> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> > Github: https://github.com/rmannibucau
>> >
>> >
>> >
>> > 2014-02-24 21:00 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
>> >> Hi @John, the problem is in the @XmlRootElement, Jackson provider
>> doesn't
>> >> need it, then i just add Jackson as a provider and everything works.
>> >>
>> >>
>> >> But i dont understand why with the default provider this doesn't work.
>> >>
>> >>
>> >> I add the jackson dependecy and
>> >> the
>> -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
>> >> property.  :)
>> >>
>> >>
>> >> 2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:
>> >>
>> >>> Can you post the code for your resource?
>> >>>
>> >>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <
>> maxtorzito@gmail.com>
>> >>> wrote:
>> >>> > Hi, im doing my first rest service. Im having problem's with
>> retrieving
>> >>> the
>> >>> > json data, when my method is called i get an:
>> >>> >
>> >>> > WARNING: javax.xml.bind.UnmarshalException
>> >>> >  - with linked exception:
>> >>> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected
>> element
>> >>> > (uri:"", local:"id"). Expected elements are
>> <{}conektaEvent>,<{}data>]
>> >>> > at
>> >>> >
>> >>>
>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
>> >>> >
>> >>> >
>> >>> > Do im missing something, any advice?
>> >>> >
>> >>> >
>> >>> > Here is the json object that im trying to receive me in the post
>> method:
>> >>> >
>> >>> > {
>> >>> >   "id":"521154c132611f5bc0000029",
>> >>> >   "type":"charge.paid",
>> >>> >   "created_at":1376867521,
>> >>> >   "data":{
>> >>> >     "object":{
>> >>> >       "id":"521154c032611f5bc0000028",
>> >>> >       "object":"charge",
>> >>> >       "livemode":false,
>> >>> >       "created_at":1376867520,
>> >>> >       "status":"paid",
>> >>> >       "currency":"MXN",
>> >>> >       "description":"Autocinema Coyote - Eterno resplandor de una
>> mente
>> >>> sin
>> >>> > recuerdos",
>> >>> >       "reference_id":"XXYYZZ-TEST1234",
>> >>> >       "failure_code":"",
>> >>> >       "failure_message":null,
>> >>> >       "amount":20000,
>> >>> >       "paid_at":1377021230,
>> >>> >       "fee":1160,
>> >>> >       payment_method":{
>> >>> >         "object":"bank_transfer_payment",
>> >>> >         "service_name":"Conekta",
>> >>> >         "service_number":"127589",
>> >>> >         "type":"banorte",
>> >>> >         "reference":"0007131"
>> >>> >       },
>> >>> >       "details":{
>> >>> >         "name":"Gustavo Delgado",
>> >>> >         "phone":5555555555,
>> >>> >         "email":"gustavo.delgado@gmail.com"
>> >>> >       }
>> >>> >     },
>> >>> >     "previous_attributes":{
>> >>> >       "status":"pending_payment",
>> >>> >       "paid_at":1377021230
>> >>> >     }
>> >>> >   }
>> >>> > }
>> >>> >
>> >>> >
>> >>> >
>> >>> > Pojo:
>> >>> >
>> >>> > @XmlAccessorType(XmlAccessType.FIELD)
>> >>> > @XmlRootElement()
>> >>> > public class ConektaEvent implements Serializable{
>> >>> >
>> >>> >     @XmlAttribute(name="id")
>> >>> >     private String id;
>> >>> >     @XmlAttribute(name="type")
>> >>> >     private String type;
>> >>> >     @XmlElement(name="created_at")
>> >>> >     private Timestamp createdAt;
>> >>> >     @XmlElement(name="data", type = ConektaData.class)
>> >>> >     private ConektaData data;
>> >>> >
>> >>> >     public ConektaEvent() {
>> >>> >     }
>> >>> >
>> >>> >     //getters and setters
>> >>> > }
>> >>> >
>> >>> >
>> >>> > I have a /WEB-INF/resources.xml
>> >>> >
>> >>> > <?xml version="1.0" encoding="UTF-8"?>
>> >>> > <resources>
>> >>> >     <Service id="json"
>> >>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>> >>> >         SkipJaxbChecks = true
>> >>> >         DropRootElement = true
>> >>> >         SupportUnwrapped = true
>> >>> >         SingleJaxbContext = true
>> >>> >     </Service>
>> >>> > </resources>
>> >>> >
>> >>> >
>> >>> >
>> >>> > Im newbie in jax-rs any help will be appreciated.
>> >>> >
>> >>> > Im using TomEE 1.6.0 JAX-RS
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> -------------------------------------------------------------------
>> >> *José Luis Cetina*
>> >> -------------------------------------------------------------------
>>
>
>
>
> --
> -------------------------------------------------------------------
> *José Luis Cetina*
> -------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by José Luis Cetina <ma...@gmail.com>.
@Romain, is jettison bundled with TomEE?


2014-02-24 14:14 GMT-06:00 John D. Ament <jo...@gmail.com>:

> Actually I was curious for the code since it seems like he's
> referencing XML in the error, but sending JSON.
>
> On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
> > cause default provider is using jaxb model so it needs a wrapper.
> > Jackson doesnt. (see jettison)
> >
> > Side note: you can put this conf in openejb-jar.xml
> > Romain Manni-Bucau
> > Twitter: @rmannibucau
> > Blog: http://rmannibucau.wordpress.com/
> > LinkedIn: http://fr.linkedin.com/in/rmannibucau
> > Github: https://github.com/rmannibucau
> >
> >
> >
> > 2014-02-24 21:00 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> >> Hi @John, the problem is in the @XmlRootElement, Jackson provider
> doesn't
> >> need it, then i just add Jackson as a provider and everything works.
> >>
> >>
> >> But i dont understand why with the default provider this doesn't work.
> >>
> >>
> >> I add the jackson dependecy and
> >> the
> -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
> >> property.  :)
> >>
> >>
> >> 2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:
> >>
> >>> Can you post the code for your resource?
> >>>
> >>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <
> maxtorzito@gmail.com>
> >>> wrote:
> >>> > Hi, im doing my first rest service. Im having problem's with
> retrieving
> >>> the
> >>> > json data, when my method is called i get an:
> >>> >
> >>> > WARNING: javax.xml.bind.UnmarshalException
> >>> >  - with linked exception:
> >>> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected
> element
> >>> > (uri:"", local:"id"). Expected elements are
> <{}conektaEvent>,<{}data>]
> >>> > at
> >>> >
> >>>
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
> >>> >
> >>> >
> >>> > Do im missing something, any advice?
> >>> >
> >>> >
> >>> > Here is the json object that im trying to receive me in the post
> method:
> >>> >
> >>> > {
> >>> >   "id":"521154c132611f5bc0000029",
> >>> >   "type":"charge.paid",
> >>> >   "created_at":1376867521,
> >>> >   "data":{
> >>> >     "object":{
> >>> >       "id":"521154c032611f5bc0000028",
> >>> >       "object":"charge",
> >>> >       "livemode":false,
> >>> >       "created_at":1376867520,
> >>> >       "status":"paid",
> >>> >       "currency":"MXN",
> >>> >       "description":"Autocinema Coyote - Eterno resplandor de una
> mente
> >>> sin
> >>> > recuerdos",
> >>> >       "reference_id":"XXYYZZ-TEST1234",
> >>> >       "failure_code":"",
> >>> >       "failure_message":null,
> >>> >       "amount":20000,
> >>> >       "paid_at":1377021230,
> >>> >       "fee":1160,
> >>> >       payment_method":{
> >>> >         "object":"bank_transfer_payment",
> >>> >         "service_name":"Conekta",
> >>> >         "service_number":"127589",
> >>> >         "type":"banorte",
> >>> >         "reference":"0007131"
> >>> >       },
> >>> >       "details":{
> >>> >         "name":"Gustavo Delgado",
> >>> >         "phone":5555555555,
> >>> >         "email":"gustavo.delgado@gmail.com"
> >>> >       }
> >>> >     },
> >>> >     "previous_attributes":{
> >>> >       "status":"pending_payment",
> >>> >       "paid_at":1377021230
> >>> >     }
> >>> >   }
> >>> > }
> >>> >
> >>> >
> >>> >
> >>> > Pojo:
> >>> >
> >>> > @XmlAccessorType(XmlAccessType.FIELD)
> >>> > @XmlRootElement()
> >>> > public class ConektaEvent implements Serializable{
> >>> >
> >>> >     @XmlAttribute(name="id")
> >>> >     private String id;
> >>> >     @XmlAttribute(name="type")
> >>> >     private String type;
> >>> >     @XmlElement(name="created_at")
> >>> >     private Timestamp createdAt;
> >>> >     @XmlElement(name="data", type = ConektaData.class)
> >>> >     private ConektaData data;
> >>> >
> >>> >     public ConektaEvent() {
> >>> >     }
> >>> >
> >>> >     //getters and setters
> >>> > }
> >>> >
> >>> >
> >>> > I have a /WEB-INF/resources.xml
> >>> >
> >>> > <?xml version="1.0" encoding="UTF-8"?>
> >>> > <resources>
> >>> >     <Service id="json"
> >>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
> >>> >         SkipJaxbChecks = true
> >>> >         DropRootElement = true
> >>> >         SupportUnwrapped = true
> >>> >         SingleJaxbContext = true
> >>> >     </Service>
> >>> > </resources>
> >>> >
> >>> >
> >>> >
> >>> > Im newbie in jax-rs any help will be appreciated.
> >>> >
> >>> > Im using TomEE 1.6.0 JAX-RS
> >>>
> >>
> >>
> >>
> >> --
> >> -------------------------------------------------------------------
> >> *José Luis Cetina*
> >> -------------------------------------------------------------------
>



-- 
-------------------------------------------------------------------
*José Luis Cetina*
-------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by Romain Manni-Bucau <rm...@gmail.com>.
hehe, jettison is a xml library providing json as output but based on xml logic.
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-02-24 21:14 GMT+01:00 John D. Ament <jo...@gmail.com>:
> Actually I was curious for the code since it seems like he's
> referencing XML in the error, but sending JSON.
>
> On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
> <rm...@gmail.com> wrote:
>> cause default provider is using jaxb model so it needs a wrapper.
>> Jackson doesnt. (see jettison)
>>
>> Side note: you can put this conf in openejb-jar.xml
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>>
>> 2014-02-24 21:00 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
>>> Hi @John, the problem is in the @XmlRootElement, Jackson provider doesn't
>>> need it, then i just add Jackson as a provider and everything works.
>>>
>>>
>>> But i dont understand why with the default provider this doesn't work.
>>>
>>>
>>> I add the jackson dependecy and
>>> the -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
>>> property.  :)
>>>
>>>
>>> 2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:
>>>
>>>> Can you post the code for your resource?
>>>>
>>>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <ma...@gmail.com>
>>>> wrote:
>>>> > Hi, im doing my first rest service. Im having problem's with retrieving
>>>> the
>>>> > json data, when my method is called i get an:
>>>> >
>>>> > WARNING: javax.xml.bind.UnmarshalException
>>>> >  - with linked exception:
>>>> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected element
>>>> > (uri:"", local:"id"). Expected elements are <{}conektaEvent>,<{}data>]
>>>> > at
>>>> >
>>>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
>>>> >
>>>> >
>>>> > Do im missing something, any advice?
>>>> >
>>>> >
>>>> > Here is the json object that im trying to receive me in the post method:
>>>> >
>>>> > {
>>>> >   "id":"521154c132611f5bc0000029",
>>>> >   "type":"charge.paid",
>>>> >   "created_at":1376867521,
>>>> >   "data":{
>>>> >     "object":{
>>>> >       "id":"521154c032611f5bc0000028",
>>>> >       "object":"charge",
>>>> >       "livemode":false,
>>>> >       "created_at":1376867520,
>>>> >       "status":"paid",
>>>> >       "currency":"MXN",
>>>> >       "description":"Autocinema Coyote - Eterno resplandor de una mente
>>>> sin
>>>> > recuerdos",
>>>> >       "reference_id":"XXYYZZ-TEST1234",
>>>> >       "failure_code":"",
>>>> >       "failure_message":null,
>>>> >       "amount":20000,
>>>> >       "paid_at":1377021230,
>>>> >       "fee":1160,
>>>> >       payment_method":{
>>>> >         "object":"bank_transfer_payment",
>>>> >         "service_name":"Conekta",
>>>> >         "service_number":"127589",
>>>> >         "type":"banorte",
>>>> >         "reference":"0007131"
>>>> >       },
>>>> >       "details":{
>>>> >         "name":"Gustavo Delgado",
>>>> >         "phone":5555555555,
>>>> >         "email":"gustavo.delgado@gmail.com"
>>>> >       }
>>>> >     },
>>>> >     "previous_attributes":{
>>>> >       "status":"pending_payment",
>>>> >       "paid_at":1377021230
>>>> >     }
>>>> >   }
>>>> > }
>>>> >
>>>> >
>>>> >
>>>> > Pojo:
>>>> >
>>>> > @XmlAccessorType(XmlAccessType.FIELD)
>>>> > @XmlRootElement()
>>>> > public class ConektaEvent implements Serializable{
>>>> >
>>>> >     @XmlAttribute(name="id")
>>>> >     private String id;
>>>> >     @XmlAttribute(name="type")
>>>> >     private String type;
>>>> >     @XmlElement(name="created_at")
>>>> >     private Timestamp createdAt;
>>>> >     @XmlElement(name="data", type = ConektaData.class)
>>>> >     private ConektaData data;
>>>> >
>>>> >     public ConektaEvent() {
>>>> >     }
>>>> >
>>>> >     //getters and setters
>>>> > }
>>>> >
>>>> >
>>>> > I have a /WEB-INF/resources.xml
>>>> >
>>>> > <?xml version="1.0" encoding="UTF-8"?>
>>>> > <resources>
>>>> >     <Service id="json"
>>>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>>> >         SkipJaxbChecks = true
>>>> >         DropRootElement = true
>>>> >         SupportUnwrapped = true
>>>> >         SingleJaxbContext = true
>>>> >     </Service>
>>>> > </resources>
>>>> >
>>>> >
>>>> >
>>>> > Im newbie in jax-rs any help will be appreciated.
>>>> >
>>>> > Im using TomEE 1.6.0 JAX-RS
>>>>
>>>
>>>
>>>
>>> --
>>> -------------------------------------------------------------------
>>> *José Luis Cetina*
>>> -------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by "John D. Ament" <jo...@gmail.com>.
Actually I was curious for the code since it seems like he's
referencing XML in the error, but sending JSON.

On Mon, Feb 24, 2014 at 3:10 PM, Romain Manni-Bucau
<rm...@gmail.com> wrote:
> cause default provider is using jaxb model so it needs a wrapper.
> Jackson doesnt. (see jettison)
>
> Side note: you can put this conf in openejb-jar.xml
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-02-24 21:00 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
>> Hi @John, the problem is in the @XmlRootElement, Jackson provider doesn't
>> need it, then i just add Jackson as a provider and everything works.
>>
>>
>> But i dont understand why with the default provider this doesn't work.
>>
>>
>> I add the jackson dependecy and
>> the -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
>> property.  :)
>>
>>
>> 2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:
>>
>>> Can you post the code for your resource?
>>>
>>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <ma...@gmail.com>
>>> wrote:
>>> > Hi, im doing my first rest service. Im having problem's with retrieving
>>> the
>>> > json data, when my method is called i get an:
>>> >
>>> > WARNING: javax.xml.bind.UnmarshalException
>>> >  - with linked exception:
>>> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected element
>>> > (uri:"", local:"id"). Expected elements are <{}conektaEvent>,<{}data>]
>>> > at
>>> >
>>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
>>> >
>>> >
>>> > Do im missing something, any advice?
>>> >
>>> >
>>> > Here is the json object that im trying to receive me in the post method:
>>> >
>>> > {
>>> >   "id":"521154c132611f5bc0000029",
>>> >   "type":"charge.paid",
>>> >   "created_at":1376867521,
>>> >   "data":{
>>> >     "object":{
>>> >       "id":"521154c032611f5bc0000028",
>>> >       "object":"charge",
>>> >       "livemode":false,
>>> >       "created_at":1376867520,
>>> >       "status":"paid",
>>> >       "currency":"MXN",
>>> >       "description":"Autocinema Coyote - Eterno resplandor de una mente
>>> sin
>>> > recuerdos",
>>> >       "reference_id":"XXYYZZ-TEST1234",
>>> >       "failure_code":"",
>>> >       "failure_message":null,
>>> >       "amount":20000,
>>> >       "paid_at":1377021230,
>>> >       "fee":1160,
>>> >       payment_method":{
>>> >         "object":"bank_transfer_payment",
>>> >         "service_name":"Conekta",
>>> >         "service_number":"127589",
>>> >         "type":"banorte",
>>> >         "reference":"0007131"
>>> >       },
>>> >       "details":{
>>> >         "name":"Gustavo Delgado",
>>> >         "phone":5555555555,
>>> >         "email":"gustavo.delgado@gmail.com"
>>> >       }
>>> >     },
>>> >     "previous_attributes":{
>>> >       "status":"pending_payment",
>>> >       "paid_at":1377021230
>>> >     }
>>> >   }
>>> > }
>>> >
>>> >
>>> >
>>> > Pojo:
>>> >
>>> > @XmlAccessorType(XmlAccessType.FIELD)
>>> > @XmlRootElement()
>>> > public class ConektaEvent implements Serializable{
>>> >
>>> >     @XmlAttribute(name="id")
>>> >     private String id;
>>> >     @XmlAttribute(name="type")
>>> >     private String type;
>>> >     @XmlElement(name="created_at")
>>> >     private Timestamp createdAt;
>>> >     @XmlElement(name="data", type = ConektaData.class)
>>> >     private ConektaData data;
>>> >
>>> >     public ConektaEvent() {
>>> >     }
>>> >
>>> >     //getters and setters
>>> > }
>>> >
>>> >
>>> > I have a /WEB-INF/resources.xml
>>> >
>>> > <?xml version="1.0" encoding="UTF-8"?>
>>> > <resources>
>>> >     <Service id="json"
>>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>> >         SkipJaxbChecks = true
>>> >         DropRootElement = true
>>> >         SupportUnwrapped = true
>>> >         SingleJaxbContext = true
>>> >     </Service>
>>> > </resources>
>>> >
>>> >
>>> >
>>> > Im newbie in jax-rs any help will be appreciated.
>>> >
>>> > Im using TomEE 1.6.0 JAX-RS
>>>
>>
>>
>>
>> --
>> -------------------------------------------------------------------
>> *José Luis Cetina*
>> -------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by Romain Manni-Bucau <rm...@gmail.com>.
cause default provider is using jaxb model so it needs a wrapper.
Jackson doesnt. (see jettison)

Side note: you can put this conf in openejb-jar.xml
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-02-24 21:00 GMT+01:00 José Luis Cetina <ma...@gmail.com>:
> Hi @John, the problem is in the @XmlRootElement, Jackson provider doesn't
> need it, then i just add Jackson as a provider and everything works.
>
>
> But i dont understand why with the default provider this doesn't work.
>
>
> I add the jackson dependecy and
> the -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
> property.  :)
>
>
> 2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:
>
>> Can you post the code for your resource?
>>
>> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <ma...@gmail.com>
>> wrote:
>> > Hi, im doing my first rest service. Im having problem's with retrieving
>> the
>> > json data, when my method is called i get an:
>> >
>> > WARNING: javax.xml.bind.UnmarshalException
>> >  - with linked exception:
>> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected element
>> > (uri:"", local:"id"). Expected elements are <{}conektaEvent>,<{}data>]
>> > at
>> >
>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
>> >
>> >
>> > Do im missing something, any advice?
>> >
>> >
>> > Here is the json object that im trying to receive me in the post method:
>> >
>> > {
>> >   "id":"521154c132611f5bc0000029",
>> >   "type":"charge.paid",
>> >   "created_at":1376867521,
>> >   "data":{
>> >     "object":{
>> >       "id":"521154c032611f5bc0000028",
>> >       "object":"charge",
>> >       "livemode":false,
>> >       "created_at":1376867520,
>> >       "status":"paid",
>> >       "currency":"MXN",
>> >       "description":"Autocinema Coyote - Eterno resplandor de una mente
>> sin
>> > recuerdos",
>> >       "reference_id":"XXYYZZ-TEST1234",
>> >       "failure_code":"",
>> >       "failure_message":null,
>> >       "amount":20000,
>> >       "paid_at":1377021230,
>> >       "fee":1160,
>> >       payment_method":{
>> >         "object":"bank_transfer_payment",
>> >         "service_name":"Conekta",
>> >         "service_number":"127589",
>> >         "type":"banorte",
>> >         "reference":"0007131"
>> >       },
>> >       "details":{
>> >         "name":"Gustavo Delgado",
>> >         "phone":5555555555,
>> >         "email":"gustavo.delgado@gmail.com"
>> >       }
>> >     },
>> >     "previous_attributes":{
>> >       "status":"pending_payment",
>> >       "paid_at":1377021230
>> >     }
>> >   }
>> > }
>> >
>> >
>> >
>> > Pojo:
>> >
>> > @XmlAccessorType(XmlAccessType.FIELD)
>> > @XmlRootElement()
>> > public class ConektaEvent implements Serializable{
>> >
>> >     @XmlAttribute(name="id")
>> >     private String id;
>> >     @XmlAttribute(name="type")
>> >     private String type;
>> >     @XmlElement(name="created_at")
>> >     private Timestamp createdAt;
>> >     @XmlElement(name="data", type = ConektaData.class)
>> >     private ConektaData data;
>> >
>> >     public ConektaEvent() {
>> >     }
>> >
>> >     //getters and setters
>> > }
>> >
>> >
>> > I have a /WEB-INF/resources.xml
>> >
>> > <?xml version="1.0" encoding="UTF-8"?>
>> > <resources>
>> >     <Service id="json"
>> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>> >         SkipJaxbChecks = true
>> >         DropRootElement = true
>> >         SupportUnwrapped = true
>> >         SingleJaxbContext = true
>> >     </Service>
>> > </resources>
>> >
>> >
>> >
>> > Im newbie in jax-rs any help will be appreciated.
>> >
>> > Im using TomEE 1.6.0 JAX-RS
>>
>
>
>
> --
> -------------------------------------------------------------------
> *José Luis Cetina*
> -------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by José Luis Cetina <ma...@gmail.com>.
Hi @John, the problem is in the @XmlRootElement, Jackson provider doesn't
need it, then i just add Jackson as a provider and everything works.


But i dont understand why with the default provider this doesn't work.


I add the jackson dependecy and
the -Dcxf.jaxrs.providers=com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
property.  :)


2014-02-24 13:47 GMT-06:00 John D. Ament <jo...@gmail.com>:

> Can you post the code for your resource?
>
> On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <ma...@gmail.com>
> wrote:
> > Hi, im doing my first rest service. Im having problem's with retrieving
> the
> > json data, when my method is called i get an:
> >
> > WARNING: javax.xml.bind.UnmarshalException
> >  - with linked exception:
> > [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected element
> > (uri:"", local:"id"). Expected elements are <{}conektaEvent>,<{}data>]
> > at
> >
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
> >
> >
> > Do im missing something, any advice?
> >
> >
> > Here is the json object that im trying to receive me in the post method:
> >
> > {
> >   "id":"521154c132611f5bc0000029",
> >   "type":"charge.paid",
> >   "created_at":1376867521,
> >   "data":{
> >     "object":{
> >       "id":"521154c032611f5bc0000028",
> >       "object":"charge",
> >       "livemode":false,
> >       "created_at":1376867520,
> >       "status":"paid",
> >       "currency":"MXN",
> >       "description":"Autocinema Coyote - Eterno resplandor de una mente
> sin
> > recuerdos",
> >       "reference_id":"XXYYZZ-TEST1234",
> >       "failure_code":"",
> >       "failure_message":null,
> >       "amount":20000,
> >       "paid_at":1377021230,
> >       "fee":1160,
> >       payment_method":{
> >         "object":"bank_transfer_payment",
> >         "service_name":"Conekta",
> >         "service_number":"127589",
> >         "type":"banorte",
> >         "reference":"0007131"
> >       },
> >       "details":{
> >         "name":"Gustavo Delgado",
> >         "phone":5555555555,
> >         "email":"gustavo.delgado@gmail.com"
> >       }
> >     },
> >     "previous_attributes":{
> >       "status":"pending_payment",
> >       "paid_at":1377021230
> >     }
> >   }
> > }
> >
> >
> >
> > Pojo:
> >
> > @XmlAccessorType(XmlAccessType.FIELD)
> > @XmlRootElement()
> > public class ConektaEvent implements Serializable{
> >
> >     @XmlAttribute(name="id")
> >     private String id;
> >     @XmlAttribute(name="type")
> >     private String type;
> >     @XmlElement(name="created_at")
> >     private Timestamp createdAt;
> >     @XmlElement(name="data", type = ConektaData.class)
> >     private ConektaData data;
> >
> >     public ConektaEvent() {
> >     }
> >
> >     //getters and setters
> > }
> >
> >
> > I have a /WEB-INF/resources.xml
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <resources>
> >     <Service id="json"
> > class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
> >         SkipJaxbChecks = true
> >         DropRootElement = true
> >         SupportUnwrapped = true
> >         SingleJaxbContext = true
> >     </Service>
> > </resources>
> >
> >
> >
> > Im newbie in jax-rs any help will be appreciated.
> >
> > Im using TomEE 1.6.0 JAX-RS
>



-- 
-------------------------------------------------------------------
*José Luis Cetina*
-------------------------------------------------------------------

Re: JAX-RS JSON unexpected element

Posted by "John D. Ament" <jo...@gmail.com>.
Can you post the code for your resource?

On Mon, Feb 24, 2014 at 2:05 PM, José Luis Cetina <ma...@gmail.com> wrote:
> Hi, im doing my first rest service. Im having problem's with retrieving the
> json data, when my method is called i get an:
>
> WARNING: javax.xml.bind.UnmarshalException
>  - with linked exception:
> [com.sun.istack.SAXParseException2; columnNumber: 0; unexpected element
> (uri:"", local:"id"). Expected elements are <{}conektaEvent>,<{}data>]
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:435)
>
>
> Do im missing something, any advice?
>
>
> Here is the json object that im trying to receive me in the post method:
>
> {
>   "id":"521154c132611f5bc0000029",
>   "type":"charge.paid",
>   "created_at":1376867521,
>   "data":{
>     "object":{
>       "id":"521154c032611f5bc0000028",
>       "object":"charge",
>       "livemode":false,
>       "created_at":1376867520,
>       "status":"paid",
>       "currency":"MXN",
>       "description":"Autocinema Coyote - Eterno resplandor de una mente sin
> recuerdos",
>       "reference_id":"XXYYZZ-TEST1234",
>       "failure_code":"",
>       "failure_message":null,
>       "amount":20000,
>       "paid_at":1377021230,
>       "fee":1160,
>       payment_method":{
>         "object":"bank_transfer_payment",
>         "service_name":"Conekta",
>         "service_number":"127589",
>         "type":"banorte",
>         "reference":"0007131"
>       },
>       "details":{
>         "name":"Gustavo Delgado",
>         "phone":5555555555,
>         "email":"gustavo.delgado@gmail.com"
>       }
>     },
>     "previous_attributes":{
>       "status":"pending_payment",
>       "paid_at":1377021230
>     }
>   }
> }
>
>
>
> Pojo:
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlRootElement()
> public class ConektaEvent implements Serializable{
>
>     @XmlAttribute(name="id")
>     private String id;
>     @XmlAttribute(name="type")
>     private String type;
>     @XmlElement(name="created_at")
>     private Timestamp createdAt;
>     @XmlElement(name="data", type = ConektaData.class)
>     private ConektaData data;
>
>     public ConektaEvent() {
>     }
>
>     //getters and setters
> }
>
>
> I have a /WEB-INF/resources.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <resources>
>     <Service id="json"
> class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>         SkipJaxbChecks = true
>         DropRootElement = true
>         SupportUnwrapped = true
>         SingleJaxbContext = true
>     </Service>
> </resources>
>
>
>
> Im newbie in jax-rs any help will be appreciated.
>
> Im using TomEE 1.6.0 JAX-RS