Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12149

Failed to invoke camel cxfrs client due to Content-Type header couldn't be retrieved and passed

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.19.4, 2.20.1
    • Fix Version/s: 2.19.5, 2.20.2, 2.21.0
    • Component/s: camel-cxfrs
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      As of Camel 2.19.x, async support is added by default in the CxfRsProducer. Considering this simple rsClient:

      <camel-cxf:rsClient id="restClient"
              address="http://localhost:8040/services/eventlogging/events" serviceClass="org.talend.esb.eventlogging.sender.rest.EventLogging"
              loggingFeatureEnabled="true">
          <camel-cxf:providers>
              <ref component-id="jsonProvider" />
          </camel-cxf:providers>
      
          <camel-cxf:headers>
               <entry key="Content-Encoding" value="UTF-8" />
               <entry key="Content-Type" value="application/json" />
          </camel-cxf:headers>
      </camel-cxf:rsClient>
      
      <camel:camelContext>
      
          <camel:route>
              <camel:from uri="timer://foo?repeatCount=1" />
      
              <camel:process ref="marshallingPreparationProcessor" />
      
              <camel:to uri="cxfrs://bean://restClient" />
          </camel:route>
      
      </camel:camelContext>

      It works well with the right Content-Type setting in Camel 2.17.x/Camel.2.18.x, but the Content-Type will be wildcard and "No message body writer has been found ..." will be thrown when invoke the restClient in Camel 2.19.x/2.20.x.

      ----------------------------
      ID: 1
      Address: http://localhost:8040/services/eventlogging/events
      Http-Method: POST
      Content-Type: */*
      Headers: {Content-Encoding=[UTF-8], Content-Type=[*/*], Content-Language=[en_US], Accept=[*/*]}
      --------------------------------------
      [mel-1) thread #0 - timer://foo] CxfRsProducer                  ERROR Failed request
      javax.ws.rs.ProcessingException: No message body writer has been found for class org.talend.esb.eventlogging.sender.rest.EventList
      , ContentType: */*
              at org.apache.cxf.jaxrs.client.AbstractClient.reportMessageHandlerProblem(AbstractClient.java:810)
              at org.apache.cxf.jaxrs.client.AbstractClient.writeBody(AbstractClient.java:497)
              at org.apache.cxf.jaxrs.client.WebClient$BodyWriter.doWriteBody(WebClient.java:1178)
              at org.apache.cxf.jaxrs.client.AbstractClient$AbstractBodyWriter.handleMessage(AbstractClient.java:1174)
              at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
              at org.apache.cxf.jaxrs.client.AbstractClient.doRunInterceptorChain(AbstractClient.java:677)
              at org.apache.cxf.jaxrs.client.WebClient.doInvokeAsync(WebClient.java:952)
              at org.apache.cxf.jaxrs.client.WebClient.doInvokeAsyncCallback(WebClient.java:915)
              at org.apache.cxf.jaxrs.client.WebClient$AsyncInvokerImpl.method(WebClient.java:1440)
              at org.apache.camel.component.cxf.jaxrs.CxfRsProducer.invokeAsyncHttpClient(CxfRsProducer.java:175)
              at org.apache.camel.component.cxf.jaxrs.CxfRsProducer.process(CxfRsProducer.java:116)

      (https://github.com/xldai/test/tree/master/test-cxfrs is created for easily reproduce this issue)

      A PR is created for fixing this issue.

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              xldai Xilai Dai
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: