Hi,

I am trying to define a custom hypermedia model (cf REST in Practice) as the 
return type of my REST service. 

With MIME type "application/json" this works, but with type 
"application/vnd.example-com.foo+json" (which is what I want) this fails, 
however. Calling the service URL gives:

"org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor writeResponseErrorMessage
WARNING: No message body writer has been found for response class ListResult."

My service method:

        @GET
        @Path("list")
        @Produces("application/vnd.example-com.foo+json")
        public ListResult retrieveList() {
                return new ListResult();
        }

My configuration code looks like this:

        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        JSONProvider prov = new JSONProvider();

        // setting custom mime types does not seem to work?
        List<String> mimeTypes = new ArrayList<String>();
        mimeTypes.add("application/vnd.example-com.foo+json");
        mimeTypes.add("application/json");
        prov.setProduceMediaTypes(mimeTypes);

        // following is regular CXF config as usual
        prov.setDropRootElement(true);
        sf.setProvider(prov);
        sf.setResourceClasses(ListService.class);
        sf.setResourceProvider(ListService.class, 
            new SingletonResourceProvider(new ListService()));
        sf.setAddress("http://localhost:9000/";);
        sf.create();


Did I miss anything? I am using CXF 2.4.1...

Thanks
Guy

Reply via email to