I have a BookMain class that returns arraylist objects. I use the REST service to get the result, but I get an error.
This is my BookMain class:
@GET @Path("/get") @Produces(MediaType.APPLICATION_XML) public ArrayList<Object> addObjects() { Book book = new Book(); book.setName("The Book"); book.setAuthor("Author"); BookStore bookstore = new BookStore(); bookstore.setName("The Bookstore"); bookstore.setLocation("UK"); ArrayList<Object> list = new ArrayList<Object>(); list.add(book); list.add(bookstore); return list; }
This is the error I get:
11 Jul, 2013 3:36:52 PM com.sun.jersey.spi.container.ContainerResponse write SEVERE: A message body writer for Java class java.util.ArrayList, and Java type java.util.ArrayList<java.lang.Object>, and MIME media type application/xml was not found 11 Jul, 2013 3:36:52 PM com.sun.jersey.spi.container. ContainerResponse write SEVERE: The registered message body writers compatible with the MIME media type are:application/xml -> com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App com.sun.jersey.core.impl.provider.entity.DocumentProvider com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App
Can someone provide me a solution for this?
Prats source share