title: Spring Integration http:outbound-gateway "no suitable HttpMessageConverter"
body: <p>We are receiving the following error:</p>
  
  <pre><code>org.springframework.web.client.RestClientException: Could not write request:
    no suitable HttpMessageConverter found for
    request type [com.company.FileRecord] and
    content type [application/x-java-serialized-object]
      at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:770)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:549)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:527)
      at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:472)
  ...
  </code></pre>
  
  <p>This is being thrown by an <code>http:outbound-gateway</code> with a <code>MappingJackson2HttpMessageConverter</code> attached, like so:</p>
  
  <pre><code>&lt;bean id="jsonMessageConverter"
        class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"&gt;
      &lt;property name="supportedMediaTypes"
                value="application/x-java-serialized-object"/&gt;
  &lt;/bean&gt;
  
  &lt;int:transformer input-channel="transformationChannel"
                   output-channel="registrationQueue"
                   ref="fileTransformer"/&gt;
  
  &lt;int:channel id="registrationQueue"/&gt;
  
  &lt;int-http:outbound-gateway id="gateway"
                             request-channel="registrationQueue"
                             message-converters="jsonMessageConverter"
                             url-expression="@urlGenerator.resolve()"
                             http-method="POST"
                             expected-response-type="javax.ws.rs.core.Response"
                             reply-channel="nullChannel"
                             error-handler="httpResponseErrorHandler"/&gt;
  </code></pre>
  
  <p>Out object being serialized is annotated for Jackson serialization:</p>
  
  <pre><code>public class FileRecord {
  
      @JsonProperty
      private final String id;
      @JsonProperty
      private final String path;
  
      ...
  
  }
  </code></pre>
  
  <p>I <em>believe</em> this was working with Spring Integration 2.2 and started to fail with a migration to 3.0.</p>
  
  <p>It jumps out at me as odd that we are trying to serialize as <code>application/x-java-serialized-object</code>. I'd expect <code>application/json</code> here. Perhaps a <code>header-enricher</code> is called for? If so, I'd like to understand why exactly this needs to expressed. Shouldn't my <code>jsonMessageConverter</code> know this?</p>