Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-510

Custom MessageBodyWriter not found


    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.1.0.GA
    • Fix Version/s: 2.2-beta-1
    • Component/s: jaxrs
    • Labels:


      I'm developping a sample JAX-RS/CDI based application, that I deploy into JBoss AS 6.0 (Final). I do not add any dependency, all my code relies on the artefacts provided by the server. So, I'm running with RESTEasy 2.1.0.GA.

      I have a few entities that are transformed into 'representation' objects that have JAXB annotations on them.

      Here is an extract of my CustomerResource :

      @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
      public class CustomerResource {
        public Response getCustomer(@PathParam("id") Integer id,
          @Context UriInfo uriInfo, @Context HttpServletRequest request) {
        @Produces({ "text/x-vcard" })
        public Response getCustomerAsVCard(@PathParam("id") Integer id, @Context UriInfo uriInfo) {

      The response objects have an instance of 'CustomerRepresentation' as an entity.

      @XmlRootElement(name = "customer")
      @XmlType(propOrder = { "firstName", "lastName", "address", "orders", "selfLinks" })
      public class CustomerRepresentation {

      And the custom Customer MessageBodyWriter :

      public class CustomerVCardMessageBodyWriter implements
      MessageBodyWriter<CustomerRepresentation> {

      Yet, when the request header 'accept' is set to 'text/x-vcard', the right CustomerResource method is called, but then I get the following error:

      13:55:11,942 WARN  [org.jboss.resteasy.core.SynchronousDispatcher] Failed executing GET /customers/1: org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException: Could not find JAXBContextFinder for media type: text/x-vcard
      at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.findJAXBContext(AbstractJAXBProvider.java:50) [:6.0.0.Final]
      at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider.java:127) [:6.0.0.Final]
      at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.writeTo(AbstractJAXBProvider.java:103) [:6.0.0.Final]
      at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117) [:6.0.0.Final]
      at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:48) [:6.0.0.Final]
      at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123) [:6.0.0.Final]
      at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:222) [:6.0.0.Final]
      at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:563) [:6.0.0.Final]
      at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:484) [:6.0.0.Final]

      Putting breakpoints in all the MBW methods shows that this class is not called, event though it was properly registered during app startup:

      13:53:21,020 INFO  [org.jboss.resteasy.integration.deployers.ResteasyIntegrationDeployer] *** Adding JAX-RS provider classes: org.bytesparadise.tools.jaxrs.sample.services.providers.CustomerVCardMessageBodyWriter

      It seems that since the returned object has JAXB annotation, the built-in JAXB provider is picked up before my custom MBW.

        Gliffy Diagrams




              • Assignee:
                bill.burke Bill Burke
                xcoulon Xavier Coulon
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: