users@jersey.java.net

Re: Custom _at_Provider

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 08 Jan 2008 13:44:38 +0100

Hi Jose,

You need to add the fully qualified class name of your class to the file:

    javax.ws.rs.ext.MessageBodyWriter

that resides in the directory:

    META-INF/services

of your application.

For more details see the EntityProvider example.

For 0.6 we will try to improve this so that such writers and readers
will be picked up automatically (just like root resource classes) and
you no longer need to use META-INF/services.

Paul.

Jose Antonio Illescas del Olmo wrote:
> I trying to do a custom Provider: for java.sql.Date and mime
> "application/xml"
>
> note: my environment is: tomcat-6, jdk-1.5 and jersey-0.5 (8 jan 2008)
>
> My Class (in classpath) is annotated as:
>
> @ProduceMime("application/xml")
> @ConsumeMime("application/xml")
> @Provider
> public class XMLProvider implements MessageBodyWriter<Object>,
> MessageBodyReader<Object>{
>
> The error is...
>
> java.lang.IllegalArgumentException: A message body writer for Java type, class java.sql.Date, and MIME media type, application/xml, was not found
> com.sun.ws.rest.impl.provider.ProviderFactoryImpl.createMessageBodyWriter
> (ProviderFactoryImpl.java:181)
> com.sun.ws.rest.spi.container.AbstractContainerResponse.writeEntity(AbstractContainerResponse.java:245)
> com.sun.ws.rest.spi.container.AbstractContainerResponse.writeEntity(AbstractContainerResponse.java
> :223)
> com.sun.ws.rest.impl.container.servlet.HttpResponseAdaptor.commitAll(HttpResponseAdaptor.java:125)
> com.sun.ws.rest.spi.container.servlet.ServletContainer.service(ServletContainer.java:130)
> javax.servlet.http.HttpServlet.service
> (HttpServlet.java:803)
>
>
> Any idea?
>
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109