I've updated Jackson dependency from 2.2.1 to 2.2.2, my test still works.

Can you open a JIRA and attach a sample maven project ? Or an existing war ?

Thanks, Sergey
On 07/06/13 15:25, Nic Fellows wrote:
Ive run mvn clean, and checked the date on 2.7.6-SNAPSHOT in our
repository, it was updated yesterday ( Thu Jun 06 2013 08:42:00 GMT+0100
(BST))

Also added @Produces and @Consumes to the class to no effect.

My spring config.xml is as follows, could it be to do with the way I'm
initializing?

     <!-- REST Server Configuration -->
     <import resource="classpath:META-INF/cxf/cxf.xml" />

     <jaxrs:server id="restServer" address="/">
         <jaxrs:serviceBeans>
             <ref bean="gabbleRestService" />
         </jaxrs:serviceBeans>
         <jaxrs:providers>
             <ref bean="jsonProvider" />
         </jaxrs:providers>
     </jaxrs:server>

     <bean id="jsonProvider"
class="uk.co.tbp.gabble.jackson.JacksonJsonProviderWrapper"/>

Cheers, Nic

On 07/06/13 14:55, Sergey Beryozkin wrote:
On 07/06/13 14:33, Nic Fellows wrote:
Thanks Sergey

I tried 2.7.6-SNAPSHOT with no luck, same error.
See

https://issues.apache.org/jira/browse/CXF-4996?page=com.atlassian.jirafisheyeplugin:fisheye-issuepanel

Can you do 'mvn clean' and double check you have 2.7.6-SNAPSHOT loaded ?

So I then tried to fix this by wrapping the provider, but still get the
same problem. I'm not 100% sure on the implementation, would you mind
taking a look at it below and let me know if i'm missing anything?

Do you really need to implement Versioned ? Other than that it looks OK
to me, also add @Produces("application/json") &
@Consumes("application/json"), though it probably should work even
without it

Sergey

Cheers, Nic

class JacksonJsonProviderWrapper implements MessageBodyReader<Object>,
MessageBodyWriter<Object>, Versioned {

      private JacksonJsonProvider jjp = new JacksonJsonProvider();
      @Override
      public Version version() {
          return jjp.version();
      }
      public void setMapper(ObjectMapper m) {
          jjp.setMapper(m);
      }

      @Override
      public boolean isWriteable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
          return jjp.isWriteable(type, genericType, annotations, mediaType);
      }

      @Override
      public long getSize(Object t, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
          return jjp.getSize(t, type, genericType, annotations, mediaType);
      }

      @Override
      public void writeTo(Object t, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
              MultivaluedMap<String, Object> httpHeaders, OutputStream
entityStream) throws IOException,
              WebApplicationException {
          jjp.writeTo(t, type, genericType, annotations, mediaType,
httpHeaders, entityStream);
      }

      @Override
      public boolean isReadable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType) {
          return jjp.isReadable(type, genericType, annotations, mediaType);
      }

      @Override
      public Object readFrom(Class<Object> type, Type genericType,
Annotation[] annotations,
                                  MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
                                  InputStream entityStream) throws
IOException, WebApplicationException {
          return jjp.readFrom(type, genericType, annotations, mediaType,
httpHeaders, entityStream);
      }

}


On 07/06/13 11:34, Sergey Beryozkin wrote:
Hi
On 07/06/13 11:29, Nic Fellows wrote:
I have just upgraded from Jackson 2.1.1 to 2.2.2 and it has caused the
following exception:

    javax.ws.rs.client.ClientException: .No message body writer has been
found for class : class uk.co.tbp.gabble.domain.User, ContentType :
application/json.

Has something changed in the way I need to configure the provider?
Known issue, has been fixed for CXF 2.7.6-SNAPSHOT, Jackson 2.2 class
hierarchy has become more complex and that confused the runtime.
Very easy workaround is to wrap Jackson 2.2.x provider in a custom
provider which only delegates to Jackson all of its calls

Cheers, Sergey
Nic



Reply via email to