Rest service + generic type List
allouli_raf Apr 15, 2011 9:15 AMhello,
i've a problem with returning List<Address> using rest service in Gatein, my Class Address is a PUJO, i have this error " Not found writer for class java.util.ArrayList and MIME type application/xml"
import javax.ws.rs.*; import org.exoplatform.services.rest.resource.ResourceContainer; public class AddressBook implements ResourceContainer{ @GET @Path("/list") @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) public List<Address> getAdressList() { List<Address> addresses = new ArrayList<Address>(); addresses.add(new Address("Shanghai", "Long Hua Street")); addresses.add(new Address("Shanghai", "Dong Quan Street")); //return contacts; return addresses; } }
when i return a string that's work, i mean addresses.toString().
and in web navigator i have this error : "
HTTP ETAT 500
javax.servlet.ServletException: javax.ws.rs.WebApplicationException
org.exoplatform.services.rest.servlet.RestServlet.onService(RestServlet.java:100)
org.exoplatform.container.web.AbstractHttpServlet.service(AbstractHttpServlet.java:116)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.exoplatform.services.rest.servlet.RestEncodingFilter.doFilter(RestEncodingFilter.java:58)
org.exoplatform.frameworks.jcr.web.ThreadLocalSessionProviderInitializedFilter.doFilter(ThreadLocalSessionProviderInitializedFilter.java:116)
org.exoplatform.services.security.web.SetCurrentIdentityFilter.doFilter(SetCurrentIdentityFilter.java:76)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
in gateIn log erro
" Not found writer for class java.util.ArrayList and MIME type application/xml"
i try this and i still have the same error message
public Response getContactArray(){ List<Address> addresses = new ArrayList<Address>(); addresses.add(new Address("Shanghai", "Long Hua Street")); addresses.add(new Address("Shanghai", "Dong Quan Street")); GenericEntity entity = new GenericEntity<List<Address>>(addresses) {}; return Response.ok(entity).build(); }
any help please