You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by rpd <Ro...@yahoo.co.uk> on 2014/01/10 13:11:28 UTC

NON-SPRING JSON array serialization workaround please??

Hi,  

The fact that Jettison incorrectly handles single-element arrays (as
http://jira.codehaus.org/browse/JETTISON-102) is unfortunately causing us
lots of problems.  Though there is a well-publicized Spring workaround we
are not using CXF with Spring (and have no plans to either).

How can I set the Jettison "serializeAsArray" parameter WITHOUT SPRING?  Is
there some way I can do it in my service code programmatically?  Can I
configure it somehow as an init param in web.xml?

Would really appreciate some help here before we resort to desparate
measures.

Rob



--
View this message in context: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: NON-SPRING JSON array serialization workaround please??

Posted by rpd <Ro...@yahoo.co.uk>.
Ok thanks - will investigate this too.  Rob
 

________________________________
 From: Sergey Beryozkin [via CXF] <ml...@n5.nabble.com>
To: rpd <Ro...@yahoo.co.uk> 
Sent: Tuesday, 14 January 2014, 12:25
Subject: Re: NON-SPRING JSON array serialization workaround please??
  


I was wrong, in fact it is already being tested, you need to do 
something like: 

<init-param> 
             <param-name>jaxrs.providers</param-name> 
             <param-value> 
                            org.apache.cxf.jaxrs.provider.json.JSONProvider( 
                              dropRootElement=false 
                              attributesToElements=true 
                              arrayKeys=a 
                              arrayKeys=b 
                            ), 
  
org.apache.cxf.jaxrs.provider.JAXBElementProvider 
                       </param-value> 
         </init-param> 

But going the Application way will offer a more flexible approach (in 
case you need to setup some Map properties, etc) 

Cheers, Sergey 

On 14/01/14 12:11, Sergey Beryozkin wrote: 

________________________________


-- 
Sergey Beryozkin 

Talend Community Coders 
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com/




________________________________
 
If you reply to this email, your message will be added to the discussion below: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442p5738536.html 
To unsubscribe from NON-SPRING JSON array serialization workaround please??, click here.
NAML



--
View this message in context: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442p5738546.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: NON-SPRING JSON array serialization workaround please??

Posted by Sergey Beryozkin <sb...@gmail.com>.
I was wrong, in fact it is already being tested, you need to do 
something like:

<init-param>
             <param-name>jaxrs.providers</param-name>
             <param-value>
                            org.apache.cxf.jaxrs.provider.json.JSONProvider(
                              dropRootElement=false
                              attributesToElements=true
                              arrayKeys=a
                              arrayKeys=b
                            ),
 
org.apache.cxf.jaxrs.provider.JAXBElementProvider
                       </param-value>
         </init-param>

But going the Application way will offer a more flexible approach (in 
case you need to setup some Map properties, etc)

Cheers, Sergey

On 14/01/14 12:11, Sergey Beryozkin wrote:
> Hi
> On 14/01/14 11:34, rpd wrote:
>> Hi,
>>
>> Thanks a lot for the reply. We are using the non Spring Servlet.
>> Presumably, then, in web.xml I would need only to include the entry...
>>
>>   <init-param>
>>      <param-name>jaxrs.properties</param-name>
>>         <param-value>
>>            serializeAsArray=true
>>         </param-value>
>>   </init-param>
>>
>> Is that it?
>>
> No, the above would set the endpoint properties, JSONProvider does not
> check them, one can do it like this:
>
> <init-param>
>    <param-name>jaxrs.providers</param-name>
>    <param-value>
>      org.apache.cxf.systest.jaxrs.BookStoreProvider1
>      org.apache.cxf.systest.jaxrs.BookStoreProvider2(a=b c=d)
>    </param-value>
>   </init-param>
>
> In this case though it won't help actually, it is only possible to
> inject simple non-collection properties and the arrayKeys JSONProvider
> property is a list. I can see it can be supported easily enough too, but
> not at the moment.
>
> The only way then for now is to register a custom JAX-RS Application
> when you can directly configure the provider
>
> Cheers, Sergey
>
>> Rob
>>
>>
>>
>> ________________________________
>>   From: Sergey Beryozkin [via CXF]
>> <ml...@n5.nabble.com>
>> To: rpd <Ro...@yahoo.co.uk>
>> Sent: Sunday, 12 January 2014, 18:24
>> Subject: Re: NON-SPRING JSON array serialization workaround please??
>>
>>
>>
>> Hi
>>
>> You can use CXFNonSpringJaxrsServlet where JSONProvider is configured
>> via either custom JAX-RS Application or declaratively, see
>> http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAX-RSservicesincontainerwithoutSpring
>>
>>
>> Cheers, Sergey
>> On 10/01/14 12:11, rpd wrote:
>>
>> ________________________________
>>
>>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: NON-SPRING JSON array serialization workaround please??

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 14/01/14 15:34, rpd wrote:
> Thanks - useful to know and it would indeed be a handy feature to be able to do this.  By "writing my own application" do you mean that I would follow...
>
> http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAX-RSservicesprogrammatically
>
> using specifically the JAXRSServerFactoryBean? Would this be outside of my web-container (Tomcat)?

No, you create your own custom JAX-RS Application and register it with 
CXFJaxrsNonSpringServlet using the parameter name as required by the 
spec, "javax.ws.rs.Application",

Cheers, Sergey

>
> Rob
>
>
> ________________________________
>   From: Sergey Beryozkin [via CXF] <ml...@n5.nabble.com>
> To: rpd <Ro...@yahoo.co.uk>
> Sent: Tuesday, 14 January 2014, 12:12
> Subject: Re: NON-SPRING JSON array serialization workaround please??
>
>
>
> Hi
> On 14/01/14 11:34, rpd wrote:
>
> ________________________________
> No, the above would set the endpoint properties, JSONProvider does not
> check them, one can do it like this:
>
> <init-param>
>     <param-name>jaxrs.providers</param-name>
>     <param-value>
>       org.apache.cxf.systest.jaxrs.BookStoreProvider1
>       org.apache.cxf.systest.jaxrs.BookStoreProvider2(a=b c=d)
>     </param-value>
>    </init-param>
>
> In this case though it won't help actually, it is only possible to
> inject simple non-collection properties and the arrayKeys JSONProvider
> property is a list. I can see it can be supported easily enough too, but
> not at the moment.
>
> The only way then for now is to register a custom JAX-RS Application
> when you can directly configure the provider
>
> Cheers, Sergey
>
> ________________________________
>
>
>
>
>
> ________________________________
>
> If you reply to this email, your message will be added to the discussion below: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442p5738535.html
> To unsubscribe from NON-SPRING JSON array serialization workaround please??, click here.
> NAML
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442p5738547.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: NON-SPRING JSON array serialization workaround please??

Posted by rpd <Ro...@yahoo.co.uk>.
Thanks - useful to know and it would indeed be a handy feature to be able to do this.  By "writing my own application" do you mean that I would follow...

http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAX-RSservicesprogrammatically

using specifically the JAXRSServerFactoryBean? Would this be outside of my web-container (Tomcat)?

Rob
 

________________________________
 From: Sergey Beryozkin [via CXF] <ml...@n5.nabble.com>
To: rpd <Ro...@yahoo.co.uk> 
Sent: Tuesday, 14 January 2014, 12:12
Subject: Re: NON-SPRING JSON array serialization workaround please??
  


Hi 
On 14/01/14 11:34, rpd wrote: 

________________________________
No, the above would set the endpoint properties, JSONProvider does not 
check them, one can do it like this: 

<init-param> 
   <param-name>jaxrs.providers</param-name> 
   <param-value> 
     org.apache.cxf.systest.jaxrs.BookStoreProvider1 
     org.apache.cxf.systest.jaxrs.BookStoreProvider2(a=b c=d) 
   </param-value> 
  </init-param> 

In this case though it won't help actually, it is only possible to 
inject simple non-collection properties and the arrayKeys JSONProvider 
property is a list. I can see it can be supported easily enough too, but 
not at the moment. 

The only way then for now is to register a custom JAX-RS Application 
when you can directly configure the provider 

Cheers, Sergey 

________________________________





________________________________
 
If you reply to this email, your message will be added to the discussion below: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442p5738535.html 
To unsubscribe from NON-SPRING JSON array serialization workaround please??, click here.
NAML



--
View this message in context: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442p5738547.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: NON-SPRING JSON array serialization workaround please??

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 14/01/14 11:34, rpd wrote:
> Hi,
>
> Thanks a lot for the reply. We are using the non Spring Servlet.  Presumably, then, in web.xml I would need only to include the entry...
>
>   <init-param>
>      <param-name>jaxrs.properties</param-name>
>         <param-value>
>            serializeAsArray=true
>         </param-value>
>   </init-param>
>
> Is that it?
>
No, the above would set the endpoint properties, JSONProvider does not 
check them, one can do it like this:

<init-param>
   <param-name>jaxrs.providers</param-name>
   <param-value>
     org.apache.cxf.systest.jaxrs.BookStoreProvider1
     org.apache.cxf.systest.jaxrs.BookStoreProvider2(a=b c=d)
   </param-value>
  </init-param>

In this case though it won't help actually, it is only possible to 
inject simple non-collection properties and the arrayKeys JSONProvider 
property is a list. I can see it can be supported easily enough too, but 
not at the moment.

The only way then for now is to register a custom JAX-RS Application 
when you can directly configure the provider

Cheers, Sergey

> Rob
>
>
>
> ________________________________
>   From: Sergey Beryozkin [via CXF] <ml...@n5.nabble.com>
> To: rpd <Ro...@yahoo.co.uk>
> Sent: Sunday, 12 January 2014, 18:24
> Subject: Re: NON-SPRING JSON array serialization workaround please??
>
>
>
> Hi
>
> You can use CXFNonSpringJaxrsServlet where JSONProvider is configured
> via either custom JAX-RS Application or declaratively, see
> http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAX-RSservicesincontainerwithoutSpring
>
> Cheers, Sergey
> On 10/01/14 12:11, rpd wrote:
>
> ________________________________
>
>


Re: NON-SPRING JSON array serialization workaround please??

Posted by rpd <Ro...@yahoo.co.uk>.
Hi,

Thanks a lot for the reply. We are using the non Spring Servlet.  Presumably, then, in web.xml I would need only to include the entry...

 <init-param>
    <param-name>jaxrs.properties</param-name>
       <param-value>
          serializeAsArray=true
       </param-value>
 </init-param>

Is that it?

Rob

 

________________________________
 From: Sergey Beryozkin [via CXF] <ml...@n5.nabble.com>
To: rpd <Ro...@yahoo.co.uk> 
Sent: Sunday, 12 January 2014, 18:24
Subject: Re: NON-SPRING JSON array serialization workaround please??
  


Hi 

You can use CXFNonSpringJaxrsServlet where JSONProvider is configured 
via either custom JAX-RS Application or declaratively, see 
http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAX-RSservicesincontainerwithoutSpring

Cheers, Sergey 
On 10/01/14 12:11, rpd wrote: 

________________________________


-- 
Sergey Beryozkin 

Talend Community Coders 
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com/




________________________________
 
If you reply to this email, your message will be added to the discussion below: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442p5738478.html  
To unsubscribe from NON-SPRING JSON array serialization workaround please??, click here.
NAML



--
View this message in context: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442p5738534.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: NON-SPRING JSON array serialization workaround please??

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

You can use CXFNonSpringJaxrsServlet where JSONProvider is configured 
via either custom JAX-RS Application or declaratively, see
http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-ConfiguringJAX-RSservicesincontainerwithoutSpring

Cheers, Sergey
On 10/01/14 12:11, rpd wrote:
> Hi,
>
> The fact that Jettison incorrectly handles single-element arrays (as
> http://jira.codehaus.org/browse/JETTISON-102) is unfortunately causing us
> lots of problems.  Though there is a well-publicized Spring workaround we
> are not using CXF with Spring (and have no plans to either).
>
> How can I set the Jettison "serializeAsArray" parameter WITHOUT SPRING?  Is
> there some way I can do it in my service code programmatically?  Can I
> configure it somehow as an init param in web.xml?
>
> Would really appreciate some help here before we resort to desparate
> measures.
>
> Rob
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/NON-SPRING-JSON-array-serialization-workaround-please-tp5738442.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com