cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iris ding <irisdin...@gmail.com>
Subject CXF fails to find a correct MessageBodyWritter for List<E> if Resource method is defined under async way
Date Sat, 13 Sep 2014 07:32:13 GMT
Hi Guys,

CXF fails to find a correct MessageBodyWritter for List<E> if Resource
method is defined under async way, 
see below example, I have two methods defined, the **/collecitons can be
returned successfully however
we will get an error for the **/asyncCollections.
@Path("/bookstore")
public class BookContinuationStore {
private final List<Book> bookList = new ArrayList<Book>();
public BookContinuationStore()
{ init(); }
@GET
@Path("/collections")
@Produces(
{ "application/xml", "application/json" })
public List<Book> getBookCollection() throws Exception { return bookList; }



@GET
@Path("/asyncCollections")
@Produces({ "application/xml", "application/json" }
)
public void getBookCollection(@Suspended AsyncResponse response) throws
Exception
{ resumeSuspendedBookList(response); }
private void resumeSuspendedBookList(final AsyncResponse response) {
executor.execute(new Runnable() {
@Override
public void run() {
try
{ Thread.sleep(2000); }
catch (InterruptedException ex)
{ // ignore }
response.resume(bookList);
}
});
}
private void init()
{ Book b1 = new Book("Iris1", 1); Book b2 = new Book("Iris2", 2);
bookList.add(b1); bookList.add(b2); }
}

I have opened CXF-6001 for this issue and uploaded a proposed fix. Looking
forward to your comments!

Iris Ding



--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-fails-to-find-a-correct-MessageBodyWritter-for-List-E-if-Resource-method-is-defined-under-async-y-tp5748709.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Mime
View raw message