tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Luis Cetina <maxtorz...@gmail.com>
Subject Re: serializeAsArray JacksonJaxbJsonProvider
Date Mon, 20 Oct 2014 15:21:56 GMT
1. If i use jackson do i have the same "serializeAsArray" trouble?  (I thought
i was using jackson, see my first mail in this conversation)

2. How do i define my Jacksonprovider, i try to do what is suggested here:
http://stackoverflow.com/questions/5951323/how-to-configure-json-format-when-using-jaxb-annotations-with-jersey


But i get an SEVERE: can't instantiate xxx.providers.MyJsonProvider
java.lang.InstantiationException: xxx.providers.MyJsonProvider



3. I cant find any doc  for configure Jackson on TomEE, is there any guide
in tomee's website?



4. I was using jackson provider correctly?

With this config:

<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>



Im using TomEE 1.7.1 JAX-RS



2014-10-20 9:50 GMT-05:00 Romain Manni-Bucau <rmannibucau@gmail.com>:

> 2014-10-20 16:49 GMT+02:00 Alex Soto <asotobu@gmail.com>:
> > BTW is johnzon already integrated in trunk of TomEE?
> >
>
> yep
>
> > 2014-10-20 16:48 GMT+02:00 Romain Manni-Bucau <rmannibucau@gmail.com>:
> >
> >> well I stopped trying to get what I want with jettison since years.
> >> The usage of jaxb tree to get json is quite broken in several places
> >> so my advice would be to use either johnzon jaxrs provider or jackson.
> >>
> >>
> >> Romain Manni-Bucau
> >> @rmannibucau
> >> http://www.tomitribe.com
> >> http://rmannibucau.wordpress.com
> >> https://github.com/rmannibucau
> >>
> >>
> >> 2014-10-20 16:44 GMT+02:00 José Luis Cetina <maxtorzito@gmail.com>:
> >> > Thanks, now its working.
> >> >
> >> > But now all of my object's are serialize as array, do i have to map
> each
> >> > pojo and set the attributes that i need to serializeAsArray ?
> >> >
> >> >
> >> > public class MyObject{
> >> >    int id;  String name;
> >> > }
> >> >
> >> > public MyObject getInfo(){
> >> >    return new MyObject();
> >> > }
> >> >
> >> > Now my json return value es:
> >> >  myObject: [{id:1, name:'any'}]
> >> >
> >> > and i expected to be:
> >> >  myObject: {id:1, name:'any'}
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > 2014-10-20 8:38 GMT-05:00 Romain Manni-Bucau <rmannibucau@gmail.com>:
> >> >
> >> >> <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 = json
> >> >>         </properties>
> >> >>     </pojo-deployment>
> >> >> </openejb-jar>
> >> >>
> >> >>
> >> >> resources.xml
> >> >>
> >> >> <resources>
> >> >>     <Service id="json"
> >> >> class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
> >> >>         serializeAsArray = true
> >> >>     </Service>
> >> >> </resources>
> >> >>
> >> >>
> >> >> jackson doesn't have any setter so you have to do your own wrapper
to
> >> >> provide the properties you want to configure (or hardcode them)
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Romain Manni-Bucau
> >> >> @rmannibucau
> >> >> http://www.tomitribe.com
> >> >> http://rmannibucau.wordpress.com
> >> >> https://github.com/rmannibucau
> >> >>
> >> >>
> >> >> 2014-10-20 15:34 GMT+02:00 José Luis Cetina <maxtorzito@gmail.com>:
> >> >> > I changed to:
> >> >> >
> >> >> > <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>
> >> >> >
> >> >> >
> >> >> > resources.xml
> >> >> >
> >> >> > <resources>
> >> >> >     <Service id="json"
> >> >> >
> class-name="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider">
> >> >> >         serializeAsArray = true
> >> >> >     </Service>
> >> >> > </resources>
> >> >> >
> >> >> >
> >> >> > and didnt work, what is the value of id in service tag? is json
> >> correct?
> >> >> do
> >> >> > i have to set the same class name in both files?? i really dont
> >> >> understand
> >> >> > this config.
> >> >> >
> >> >> > 2014-10-19 2:24 GMT-05:00 Romain Manni-Bucau <
> rmannibucau@gmail.com>:
> >> >> >
> >> >> >> If you have a custom jaxrs application class-name should be
its
> name.
> >> >> >>
> >> >> >> And once you use resources, providers values should be their
ids
> >> (json
> >> >> >> here) in openejb-jar.
> >> >> >>  Hi,
> >> >> >> I usually add my own @provider / "extends
> JacksonJaxbJsonProvider")
> >> >> >>
> >> >> >> and set all my needed objectmapper options there.
> >> >> >>
> >> >> >> br hw
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> --
> >> >> >> View this message in context:
> >> >> >>
> >> >> >>
> >> >>
> >>
> http://tomee-openejb.979440.n4.nabble.com/serializeAsArray-JacksonJaxbJsonProvider-tp4672427p4672431.html
> >> >> >> Sent from the TomEE Users mailing list archive at Nabble.com.
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > -------------------------------------------------------------------
> >> >> > *José Luis Cetina*
> >> >> > -------------------------------------------------------------------
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > -------------------------------------------------------------------
> >> > *José Luis Cetina*
> >> > -------------------------------------------------------------------
> >>
> >
> >
> >
> > --
> > +----------------------------------------------------------+
> >   Alex Soto Bueno - Computer Engineer
> >   www.lordofthejars.com
> > +----------------------------------------------------------+
>



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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message