You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "kirys.it" <ki...@neoteroi.org> on 2015/05/18 17:06:09 UTC

Re: Serialize ArrayList as JSON array?

On 03/05/2015 05:27 PM, bibhas wrote:
> Never mind. I found out that I had to add serializeAsArray = true in my
> resources.xml:
>
> <resources>
>      <Service id="jsonProvider"
> class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>          dropRootElement=true
>          supportUnwrapped = true
>          dropCollectionWrapperElement=true
>          serializeAsArray = true
>      </Service>
> </resources>
>
> Why does CXF have such insane defaults I will never know.
>

Did you put this into war resource file?

Fwd: Serialize ArrayList as JSON array?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
didnt investigated but weird

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

---------- Forwarded message ----------
From: kirys.it <ki...@neoteroi.org>
Date: 2015-05-19 18:18 GMT+02:00
Subject: Re: Serialize ArrayList as JSON array?
To: users@tomee.apache.org


On 05/19/2015 04:03 PM, Romain Manni-Bucau wrote:

> jdk1.7 or 1.8 doesnt make any change, tomee
> 1.7.2/1.7.3-SNAPSHOT/7.0.0-SNAPSHOT (but got it working on 1.7.1 as well
> even if I dont use it anymore since months)
>

I've replaced official java spec with this:
        <dependency>
 <groupId>org.apache.geronimo.specs</groupId>
 <artifactId>geronimo-json_1.0_spec</artifactId>
             <version>1.0-alpha-1</version>
        </dependency>
and it works now

Re: Serialize ArrayList as JSON array?

Posted by "kirys.it" <ki...@neoteroi.org>.
On 05/19/2015 04:03 PM, Romain Manni-Bucau wrote:
> jdk1.7 or 1.8 doesnt make any change, tomee 
> 1.7.2/1.7.3-SNAPSHOT/7.0.0-SNAPSHOT (but got it working on 1.7.1 as 
> well even if I dont use it anymore since months)

I've replaced official java spec with this:
         <dependency>
  <groupId>org.apache.geronimo.specs</groupId>
  <artifactId>geronimo-json_1.0_spec</artifactId>
              <version>1.0-alpha-1</version>
         </dependency>
and it works now

Re: Serialize ArrayList as JSON array?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2015-05-19 14:51 GMT+02:00 kirys.it <ki...@neoteroi.org>:

> On 05/19/2015 10:27 AM, Romain Manni-Bucau wrote:
>
>> then you surely have something broken in your setup, I use this everyday
>> in
>> tomee 1.7 and 7.x, try to rreproduce on github maybe
>>
>>
>>  I'll try to make some tests
> which edition do you use and jdk? I was trying 1.7.1 plume and using
> jdk8u45
> I would start from your setup (that is know to work) and the going step by
> step to mine to see which element cause the issue.
>

jdk1.7 or 1.8 doesnt make any change, tomee
1.7.2/1.7.3-SNAPSHOT/7.0.0-SNAPSHOT (but got it working on 1.7.1 as well
even if I dont use it anymore since months)


> Cya
> K.
>

Re: Serialize ArrayList as JSON array?

Posted by "kirys.it" <ki...@neoteroi.org>.
On 05/19/2015 10:27 AM, Romain Manni-Bucau wrote:
> then you surely have something broken in your setup, I use this everyday in
> tomee 1.7 and 7.x, try to rreproduce on github maybe
>
>
I'll try to make some tests
which edition do you use and jdk? I was trying 1.7.1 plume and using jdk8u45
I would start from your setup (that is know to work) and the going step 
by step to mine to see which element cause the issue.
Cya
K.

Re: Serialize ArrayList as JSON array?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
then you surely have something broken in your setup, I use this everyday in
tomee 1.7 and 7.x, try to rreproduce on github maybe


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-05-19 9:56 GMT+02:00 kirys.it <ki...@neoteroi.org>:

> On 05/18/2015 09:53 PM, Romain Manni-Bucau wrote:
>
>> yes or the geronimo one but this one is ok
>>
>>  Still this
> May 19, 2015 9:55:26 AM
> org.apache.openejb.observer.ObserverManager$MethodInvocation invoke
> SEVERE: error invoking
> org.apache.tomee.webservices.TomeeJaxRsService@6a396c1e
> java.util.ServiceConfigurationError: javax.json.spi.JsonProvider: Provider
> org.apache.johnzon.core.JsonProviderImpl not a subtype
>
>         <dependency>
>              <groupId>javax.json</groupId>
>              <artifactId>javax.json-api</artifactId>
>              <version>1.0</version>
>         </dependency>
>         <dependency>
>         <groupId>org.apache.johnzon</groupId>
>         <artifactId>johnzon-core</artifactId>
>         <version>0.7-incubating</version>
>       </dependency>
>       <dependency>
>         <groupId>org.apache.johnzon</groupId>
>         <artifactId>johnzon-mapper</artifactId>
>         <version>0.7-incubating</version>
>       </dependency>
>       <dependency>
>         <groupId>org.apache.johnzon</groupId>
>         <artifactId>johnzon-jaxrs</artifactId>
>         <version>0.7-incubating</version>
>       </dependency>
>
>

Re: Serialize ArrayList as JSON array?

Posted by "kirys.it" <ki...@neoteroi.org>.
On 05/18/2015 09:53 PM, Romain Manni-Bucau wrote:
> yes or the geronimo one but this one is ok
>
Still this
May 19, 2015 9:55:26 AM 
org.apache.openejb.observer.ObserverManager$MethodInvocation invoke
SEVERE: error invoking 
org.apache.tomee.webservices.TomeeJaxRsService@6a396c1e
java.util.ServiceConfigurationError: javax.json.spi.JsonProvider: 
Provider org.apache.johnzon.core.JsonProviderImpl not a subtype

         <dependency>
              <groupId>javax.json</groupId>
              <artifactId>javax.json-api</artifactId>
              <version>1.0</version>
         </dependency>
         <dependency>
         <groupId>org.apache.johnzon</groupId>
         <artifactId>johnzon-core</artifactId>
         <version>0.7-incubating</version>
       </dependency>
       <dependency>
         <groupId>org.apache.johnzon</groupId>
         <artifactId>johnzon-mapper</artifactId>
         <version>0.7-incubating</version>
       </dependency>
       <dependency>
         <groupId>org.apache.johnzon</groupId>
         <artifactId>johnzon-jaxrs</artifactId>
         <version>0.7-incubating</version>
       </dependency>


Re: Serialize ArrayList as JSON array?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
yes or the geronimo one but this one is ok


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-05-18 21:47 GMT+02:00 kirys.it <ki...@neoteroi.org>:

> On 05/18/2015 09:04 PM, Romain Manni-Bucau wrote:
>
>> you miss jsonp api jar
>>
>>
>>
>>  this?
>         <dependency>
>              <groupId>javax.json</groupId>
>              <artifactId>javax.json-api</artifactId>
>              <version>1.0</version>
>         </dependency>
>
>

Re: Serialize ArrayList as JSON array?

Posted by "kirys.it" <ki...@neoteroi.org>.
On 05/18/2015 09:04 PM, Romain Manni-Bucau wrote:
> you miss jsonp api jar
>
>
>
this?
         <dependency>
              <groupId>javax.json</groupId>
              <artifactId>javax.json-api</artifactId>
              <version>1.0</version>
         </dependency>


Re: Serialize ArrayList as JSON array?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
you miss jsonp api jar


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-05-18 20:54 GMT+02:00 kirys.it <ki...@neoteroi.org>:

> On 05/18/2015 07:09 PM, Romain Manni-Bucau wrote:
>
>> Yes you can
>>
>> https://rmannibucau.wordpress.com/2014/12/02/apache-johnzon-more-configuration-and-tomee-integration/
>>
>>
> SEVERE: error invoking
> org.apache.tomee.webservices.TomeeJaxRsService@6a396c1e
> java.util.ServiceConfigurationError: javax.json.spi.JsonProvider: Provider
> org.apache.johnzon.core.JsonProviderImpl not a subtype
> johnzon 0.7-incubating
> it seems that in 2.0 il will be the new default provider so maybe i'm
> doing something wrong...
>
>     <Service id="johnzon"
> class-name="org.apache.johnzon.jaxrs.ConfigurableJohnzonProvider">
>         accessModeName = method
>         supportHiddenAccess = true
>         doCloseOnStreams = false
>         version = 2
>         skipNull = true
>         skipEmptyArray = true
>     </Service>
>
>     <pojo-deployment class-name="jaxrs-application">
>         <properties>
>             cxf.jaxrs.providers = johnzon
>
>             # this one is not mandatory but recommanded
>             cxf.jaxrs.skip-provider-scanning = true
>         </properties>
>     </pojo-deployment>
>
>
>         <dependency>
>         <groupId>org.apache.johnzon</groupId>
>         <artifactId>johnzon-core</artifactId>
>         <version>0.7-incubating</version>
>       </dependency>
>       <dependency>
>         <groupId>org.apache.johnzon</groupId>
>         <artifactId>johnzon-mapper</artifactId>
>         <version>0.7-incubating</version>
>       </dependency>
>       <dependency>
>         <groupId>org.apache.johnzon</groupId>
>         <artifactId>johnzon-jaxrs</artifactId>
>         <version>0.7-incubating</version>
>       </dependency>
>
>
>

Re: Serialize ArrayList as JSON array?

Posted by "kirys.it" <ki...@neoteroi.org>.
On 05/18/2015 07:09 PM, Romain Manni-Bucau wrote:
> Yes you can
> https://rmannibucau.wordpress.com/2014/12/02/apache-johnzon-more-configuration-and-tomee-integration/
>

SEVERE: error invoking 
org.apache.tomee.webservices.TomeeJaxRsService@6a396c1e
java.util.ServiceConfigurationError: javax.json.spi.JsonProvider: 
Provider org.apache.johnzon.core.JsonProviderImpl not a subtype
johnzon 0.7-incubating
it seems that in 2.0 il will be the new default provider so maybe i'm 
doing something wrong...

     <Service id="johnzon" 
class-name="org.apache.johnzon.jaxrs.ConfigurableJohnzonProvider">
         accessModeName = method
         supportHiddenAccess = true
         doCloseOnStreams = false
         version = 2
         skipNull = true
         skipEmptyArray = true
     </Service>

     <pojo-deployment class-name="jaxrs-application">
         <properties>
             cxf.jaxrs.providers = johnzon

             # this one is not mandatory but recommanded
             cxf.jaxrs.skip-provider-scanning = true
         </properties>
     </pojo-deployment>


         <dependency>
         <groupId>org.apache.johnzon</groupId>
         <artifactId>johnzon-core</artifactId>
         <version>0.7-incubating</version>
       </dependency>
       <dependency>
         <groupId>org.apache.johnzon</groupId>
         <artifactId>johnzon-mapper</artifactId>
         <version>0.7-incubating</version>
       </dependency>
       <dependency>
         <groupId>org.apache.johnzon</groupId>
         <artifactId>johnzon-jaxrs</artifactId>
         <version>0.7-incubating</version>
       </dependency>



Re: Serialize ArrayList as JSON array?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Yes you can
https://rmannibucau.wordpress.com/2014/12/02/apache-johnzon-more-configuration-and-tomee-integration/
 Le 18 mai 2015 18:23, "Kirys" <ki...@neoteroi.org> a écrit :

> Sorry again
> I've found how to set it into openejb-jar
> But it still collapse array of one element into json.
> Is there a correct set of parameters or should I use another provider
> (Jackson?)?
> Thank you
> K
>  On 18 May 2015 17:06, "kirys.it" <ki...@neoteroi.org> wrote:
>
> > On 03/05/2015 05:27 PM, bibhas wrote:
> >
> >> Never mind. I found out that I had to add serializeAsArray = true in my
> >> resources.xml:
> >>
> >> <resources>
> >>      <Service id="jsonProvider"
> >> class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
> >>          dropRootElement=true
> >>          supportUnwrapped = true
> >>          dropCollectionWrapperElement=true
> >>          serializeAsArray = true
> >>      </Service>
> >> </resources>
> >>
> >> Why does CXF have such insane defaults I will never know.
> >>
> >>
> > Did you put this into war resource file?
> >
>

Re: Serialize ArrayList as JSON array?

Posted by Kirys <ki...@neoteroi.org>.
Sorry again
I've found how to set it into openejb-jar
But it still collapse array of one element into json.
Is there a correct set of parameters or should I use another provider
(Jackson?)?
Thank you
K
 On 18 May 2015 17:06, "kirys.it" <ki...@neoteroi.org> wrote:

> On 03/05/2015 05:27 PM, bibhas wrote:
>
>> Never mind. I found out that I had to add serializeAsArray = true in my
>> resources.xml:
>>
>> <resources>
>>      <Service id="jsonProvider"
>> class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>>          dropRootElement=true
>>          supportUnwrapped = true
>>          dropCollectionWrapperElement=true
>>          serializeAsArray = true
>>      </Service>
>> </resources>
>>
>> Why does CXF have such insane defaults I will never know.
>>
>>
> Did you put this into war resource file?
>