users@jersey.java.net

Re: Custom _at_Provider

From: Jose Antonio Illescas del Olmo <jose.illescas_at_gmail.com>
Date: Tue, 8 Jan 2008 16:12:03 +0100

Thank you Paul, but after add these two lines (to
[MY_WAR]/META-INF/services/javax.ws.rs.ext.MessageBodyWriter file):

    es.rbcdexia.rest.provider.XMLProvider
    es.rbcdexia.rest.provider.TXTProvider

I obtain same error...

    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)


  note: both Provider classes are stored in [MY_WAR]/WEB-INF/lib/some.jar

On Jan 8, 2008 1:44 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> 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
>