You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Obele, Azubuko" <Az...@morganstanleysmithbarney.com> on 2010/07/15 16:46:30 UTC

Overriding the default Jettison JSON Provider

I've defined a jaxrs server like:

<jaxrs:server id="myService" address="http://localhost:19300/ai/" >

    <jaxrs:serviceBeans>
        <ref bean="resourceService" />
    </jaxrs:serviceBeans>
    <jaxrs:providers>
           <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider">
            <property name="mapper">
             <bean
                class="com.rest.json.ObjectMapperFactoryBean">
            </bean>
            </property>
           </bean>
        <ref bean="jaxbElementProvider" />
    </jaxrs:providers>
    <jaxrs:extensionMappings>
        <entry key="json" value="application/json" />
           <entry key="xml" value="application/xml" />
        </jaxrs:extensionMappings>
 </jaxrs:server>

- For some reason, when I request Json from the service the org.apache.cxf.jaxrs.provider.JSONProvider#readFrom method is used instead of the jackson provider. How can I remove/override the built-provider and replace it with Jackson?

Thanks,

--------------------------------------------------------------------------
Important Notice to Recipients:
 
It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions. Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley Smith Barney.
 
The sender of this e-mail is an employee of Morgan Stanley Smith Barney LLC. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately.  Erroneous transmission is not intended to waive confidentiality or privilege. Morgan Stanley Smith Barney reserves the right, to the extent permitted under applicable law, to monitor electronic communications. By e-mailing with Morgan Stanley Smith Barney you consent to the foregoing.

RE: Overriding the default Jettison JSON Provider

Posted by "Obele, Azubuko" <Az...@morganstanleysmithbarney.com>.
Sergey,

Thanks for the reply. Turns out to be a stupid mistake on my part: the Jackson JSON Provider was being used correctly on the server but it wasn't configured for use on the client. I finally picked up on it when I realized the exception was occurring during the readFrom call. 

-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Sent: Thursday, July 15, 2010 5:28 PM
To: users@cxf.apache.org
Subject: Re: Overriding the default Jettison JSON Provider

Hi - this should really work - the only reason that I can think of is that org.codehaus.jackson.jaxrs.JacksonJsonProvider just don't confirm that a given stream is readable - can you confirm that it is actually being invoked ? You can extend JacksonJsonProvider if needed and add log statements confirming it's been invoked and its isReadbale returns true, etc

cheers, Sergey

On Thu, Jul 15, 2010 at 3:46 PM, Obele, Azubuko < Azubuko.Obele@morganstanleysmithbarney.com> wrote:

> I've defined a jaxrs server like:
>
> <jaxrs:server id="myService" address="http://localhost:19300/ai/" >
>
>    <jaxrs:serviceBeans>
>        <ref bean="resourceService" />
>    </jaxrs:serviceBeans>
>    <jaxrs:providers>
>           <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider">
>            <property name="mapper">
>             <bean
>                class="com.rest.json.ObjectMapperFactoryBean">
>            </bean>
>            </property>
>           </bean>
>        <ref bean="jaxbElementProvider" />
>    </jaxrs:providers>
>    <jaxrs:extensionMappings>
>        <entry key="json" value="application/json" />
>           <entry key="xml" value="application/xml" />
>        </jaxrs:extensionMappings>
>  </jaxrs:server>
>
> - For some reason, when I request Json from the service the 
> org.apache.cxf.jaxrs.provider.JSONProvider#readFrom method is used 
> instead of the jackson provider. How can I remove/override the 
> built-provider and replace it with Jackson?
>
> Thanks,
>
> ----------------------------------------------------------------------
> ----
> Important Notice to Recipients:
>
> It is important that you do not use e-mail to request, authorize or 
> effect the purchase or sale of any security or commodity, to send fund 
> transfer instructions, or to effect any other transactions. Any such 
> request, orders, or instructions that you send will not be accepted 
> and will not be processed by Morgan Stanley Smith Barney.
>
> The sender of this e-mail is an employee of Morgan Stanley Smith 
> Barney LLC. If you have received this communication in error, please 
> destroy all electronic and paper copies and notify the sender 
> immediately.  Erroneous transmission is not intended to waive 
> confidentiality or privilege. Morgan Stanley Smith Barney reserves the 
> right, to the extent permitted under applicable law, to monitor 
> electronic communications. By e-mailing with Morgan Stanley Smith Barney you consent to the foregoing.
>

--------------------------------------------------------------------------
Important Notice to Recipients:
 
It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions. Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley Smith Barney.
 
The sender of this e-mail is an employee of Morgan Stanley Smith Barney LLC. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately.  Erroneous transmission is not intended to waive confidentiality or privilege. Morgan Stanley Smith Barney reserves the right, to the extent permitted under applicable law, to monitor electronic communications. By e-mailing with Morgan Stanley Smith Barney you consent to the foregoing.

Re: Overriding the default Jettison JSON Provider

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi - this should really work - the only reason that I can think of is that
org.codehaus.jackson.jaxrs.JacksonJsonProvider just don't confirm that a
given stream is readable - can you confirm that it is actually being invoked
? You can extend JacksonJsonProvider if needed and add log statements
confirming it's been invoked and its isReadbale returns true, etc

cheers, Sergey

On Thu, Jul 15, 2010 at 3:46 PM, Obele, Azubuko <
Azubuko.Obele@morganstanleysmithbarney.com> wrote:

> I've defined a jaxrs server like:
>
> <jaxrs:server id="myService" address="http://localhost:19300/ai/" >
>
>    <jaxrs:serviceBeans>
>        <ref bean="resourceService" />
>    </jaxrs:serviceBeans>
>    <jaxrs:providers>
>           <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider">
>            <property name="mapper">
>             <bean
>                class="com.rest.json.ObjectMapperFactoryBean">
>            </bean>
>            </property>
>           </bean>
>        <ref bean="jaxbElementProvider" />
>    </jaxrs:providers>
>    <jaxrs:extensionMappings>
>        <entry key="json" value="application/json" />
>           <entry key="xml" value="application/xml" />
>        </jaxrs:extensionMappings>
>  </jaxrs:server>
>
> - For some reason, when I request Json from the service the
> org.apache.cxf.jaxrs.provider.JSONProvider#readFrom method is used instead
> of the jackson provider. How can I remove/override the built-provider and
> replace it with Jackson?
>
> Thanks,
>
> --------------------------------------------------------------------------
> Important Notice to Recipients:
>
> It is important that you do not use e-mail to request, authorize or effect
> the purchase or sale of any security or commodity, to send fund transfer
> instructions, or to effect any other transactions. Any such request, orders,
> or instructions that you send will not be accepted and will not be processed
> by Morgan Stanley Smith Barney.
>
> The sender of this e-mail is an employee of Morgan Stanley Smith Barney
> LLC. If you have received this communication in error, please destroy all
> electronic and paper copies and notify the sender immediately.  Erroneous
> transmission is not intended to waive confidentiality or privilege. Morgan
> Stanley Smith Barney reserves the right, to the extent permitted under
> applicable law, to monitor electronic communications. By e-mailing with
> Morgan Stanley Smith Barney you consent to the foregoing.
>