Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3247

CXF JAX-RS does not recognize MessageBodyReader/MessageBodyWriter with no generic parameters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.3.1
    • 2.3.2, 2.4
    • JAX-RS
    • None
    • Moderate

    Description

      Chapter 19, Example 6_02 (page 230) from Bill Burke's RESTful Java with JAX-RS book is working with RESTEasy but not CXF (I'm using 2.3.2-SNAPSHOT). This example is freely available in the RESTEasy download[1].

      This example creates a new MessageBodyReader and MessageBodyWriter for exchanging Java objects directly using REST.

      Steps to duplicate:

      1.) After downloading and extracting RESTEasy and navigating to this folder: resteasy-jaxrs-2.1.0.GA/examples/oreilly-workbook/ex06_2 , type mvn clean install. You'll see a before/after response using the RESTEasy library:

      -------------------------------------------------------
      T E S T S
      -------------------------------------------------------
      Running com.restfully.shop.test.CustomerResourceTest

          • Create a new Customer ***
            15.01.2011 17:21:14 org.jboss.resteasy.spi.ResteasyDeployment
            INFO: Deploying javax.ws.rs.core.Application: class com.restfully.shop.services.ShoppingApplication
            15.01.2011 17:21:14 org.jboss.resteasy.spi.ResteasyDeployment
            INFO: Adding singleton resource com.restfully.shop.services.CustomerResource from Application javax.ws.rs.core.Application
            Created customer 1
            Location: http://localhost:9095/customers/1
          • GET Created Customer **
            Content-Type: application/x-java-serialized-object
            Customer {id=1, firstName='Bill', lastName='Burke', street='256 Clarendon Street', city='Boston', state='MA', zip='02115', country='USA'}
            • After Update ***
              Content-Type: application/x-java-serialized-object
              Customer {id=1, firstName='William', lastName='Burke', street='256 Clarendon Street', city='Boston', state='MA', zip='02115', country='USA'}

              Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.344 sec

      2.) Convert the sample to using CXF's version of JAX-RS by making the following two changes (I've used these two steps with success in nearly all the other examples up to this one):

      – Switching the servlet in the web.xml:

      <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>

      <!--servlet-class>

      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher

      </servlet-class-->

      – Switching the dependency in the pom.xml:

      <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxrs</artifactId>
      <version>2.3.2-SNAPSHOT</version>
      </dependency>
      <!--dependency>

      <groupId>org.jboss.resteasy</groupId>

      <artifactId>resteasy-jaxrs</artifactId>

      <version>2.1.0.GA</version>

      </dependency-->

      3.) Running mvn clean install again will return this error:

      -------------------------------------------------------
      T E S T S
      -------------------------------------------------------
      Running com.restfully.shop.test.CustomerResourceTest

          • Create a new Customer ***
            15.01.2011 17:22:52 org.apache.cxf.transport.servlet.CXFNonSpringServlet loadBusNoConfig
            INFO: Load the bus without application context
            15.01.2011 17:22:52 org.springframework.context.support.AbstractApplicationContext prepareRefresh
            INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@23b561a2: startup date [Sat Jan 15 17:22:52 EST 2011]; root of context hierarchy
            15.01.2011 17:22:52 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
            INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
            15.01.2011 17:22:52 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
            INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-jaxrs-binding.xml]
            15.01.2011 17:22:52 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
            INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-xml.xml]
            15.01.2011 17:22:52 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
            INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-http.xml]
            15.01.2011 17:22:52 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
            INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2f78743b: defining beans [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.service.factory.FactoryBeanListenerManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory]; root of factory hierarchy
            15.01.2011 17:22:53 org.apache.cxf.transport.servlet.AbstractCXFServlet replaceDestinationFactory
            INFO: Replaced the http destination factory with servlet transport factory
            15.01.2011 17:22:53 org.apache.cxf.jaxrs.utils.ResourceUtils checkMethodDispatcher
            WARNUNG: No resource methods have been found for resource class com.restfully.shop.services.JavaMarshaller
            15.01.2011 17:22:53 org.apache.cxf.endpoint.ServerImpl initDestination
            INFO: Setting the server's publish address to be /
            15.01.2011 17:22:53 org.apache.cxf.jaxrs.utils.JAXRSUtils readFromMessageBody
            WARNUNG: No message body reader has been found for request class Customer, ContentType : application/x-java-serialized-object.
            15.01.2011 17:22:53 org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
            WARNUNG: WebApplicationException has been caught : no cause is available
            Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.919 sec <<< FAILURE!

      Results :

      Failed tests:
      testCustomerResource(com.restfully.shop.test.CustomerResourceTest)

      Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

      [1] http://sourceforge.net/projects/resteasy/files/Resteasy%20JAX-RS/

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            gmazza Glen Mazza
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: