java - JAX-RS NoMessageBodyWriterFoundFailure -


the method of jax-rs application:

@get @produces (mediatype.application_json) public list <document> getdocumentlist(@headerparam("range") string headerrange) { int [] range = getrangefromheader(headerrange); return facade.listbyrange(range); } 

working properly. if modifications the:

@get @produces(mediatype.application_json) public response getdocumentlist(@headerparam("range") string headerrange) {    int[] range = getrangefromheader(headerrange);    return response.ok(           facade.listbyrange(range))          .header("content-range", getcontentrangestr(range)).build(); } 

i receive error

...nomessagebodywriterfoundfailure: not find messagebodywriter response object of type: java.util.arraylist of media type: application/json... 

server jboss 7.1.1

please tell me what's wrong.

ps.sorry bad english.

the snippet below should trick.

@get @produces(mediatype.application_json) public response getdocumentlist(@headerparam("range") string headerrange) {    int[] range = getrangefromheader(headerrange);    return response.ok(         new genericentity<list<document>>( (list<document>)facade.listbyrange(range))          )          .header("content-range", getcontentrangestr(range)).build(); } 

the anonymous genericentity subclass required supply correct type information (otherwise erased compiler) writer.

-- edit

the reason why code worked using org.jboss.resteasy.resteasy-jackson-provider not org.jboss.resteasy.resteasy-jettison-provider resides on fundamental difference between 2 providers:

  • the former (jackson) relies on javabean model, discovering properties of objects serialize, , needs no type information
  • the latter (jettyson) relies on jaxb annotations, needs underlying type information, erased compiler.

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -