title: Spring Integration: HTTP Inbound Gateway - using JSON to Object transformer for HashMap
body: <p>I am trying to setup a Spring Integration based Restful service. I am trying to avoid creating individual objects for request and response but instead use a HashMap for simple functions such as <strong>isUserAvailableForRegistration</strong> at service.</p>
  
  <p>e.g</p>
  
  <pre><code>HashMap&lt;String, String&gt; isUserAvailableForRegistration(HashMap&lt;String,String&gt; request)
  </code></pre>
  
  <p>The following is the integration related context information:</p>
  
  <pre><code>&lt;bean class="org.springframework.integration.http.inbound.UriPathHandlerMapping"/&gt;
  
  &lt;int-http:inbound-gateway id="inboundGateway"
      request-channel="incoming" reply-channel="outgoing" 
      supported-methods="POST" reply-timeout="5000"
      path="/customer/isUserAvailable" /&gt;
  
  &lt;int:channel id="incoming" /&gt;
  &lt;int:channel id="outgoing" /&gt;
  
  &lt;int:service-activator id="activator" input-channel="incoming" ref="customerManagementGateway"
      method="isUserAvailableForRegistration" output-channel="outgoing" requires-reply="true" /&gt;
  
  &lt;int:object-to-json-transformer id="outgoingJsonConverter"
      input-channel="outgoing" /&gt;
  
  &lt;int:json-to-object-transformer id="incomingJsonConverter" input-channel="incoming" type="java.util.HashMap"  /&gt;
  </code></pre>
  
  <p>While I can successfully test that I could marshall HashMap to JSON successfully, I am missing the configuration to unmarshall JSON data into HashMap.</p>
  
  <p>I get the following exception:</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.integration.dispatcher.AggregateMessageDeliveryException: All attempts to deliver Message to MessageHandlers failed. Multiple causes:
      failed to transform message
      org.springframework.expression.AccessException: Problem invoking method: public java.util.Map com.testapp.customer.CustomerManagementServiceActivator.isUserAvailableForRegistration(java.util.Map)
  See below for the stacktrace of the first cause.
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  root cause
  
  org.springframework.integration.dispatcher.AggregateMessageDeliveryException: All attempts to deliver Message to MessageHandlers failed. Multiple causes:
      failed to transform message
      org.springframework.expression.AccessException: Problem invoking method: public java.util.Map com.testapp.customer.CustomerManagementServiceActivator.isUserAvailableForRegistration(java.util.Map)
  See below for the stacktrace of the first cause.
      org.springframework.integration.dispatcher.UnicastingDispatcher.handleExceptions(UnicastingDispatcher.java:164)
      org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:127)
      org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:101)
      org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61)
      org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
      org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
      org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:318)
      org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
      org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:233)
      org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:207)
      org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:378)
      org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:95)
      org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  root cause
  
  org.springframework.integration.transformer.MessageTransformationException: failed to transform message
      org.springframework.integration.transformer.AbstractTransformer.transform(AbstractTransformer.java:44)
      org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:67)
      org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:97)
      org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
      org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:114)
      org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:101)
      org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61)
      org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
      org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
      org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:318)
      org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
      org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:233)
      org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:207)
      org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:378)
      org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:95)
      org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  root cause
  
  java.lang.ClassCastException: [B cannot be cast to java.lang.String
      org.springframework.integration.json.JsonToObjectTransformer.transformPayload(JsonToObjectTransformer.java:30)
      org.springframework.integration.transformer.AbstractPayloadTransformer.doTransform(AbstractPayloadTransformer.java:33)
      org.springframework.integration.transformer.AbstractTransformer.transform(AbstractTransformer.java:33)
      org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:67)
      org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:97)
      org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
      org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:114)
      org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:101)
      org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61)
      org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
      org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
      org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:318)
      org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
      org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:233)
      org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:207)
      org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:378)
      org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:95)
      org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>
  
  <p>Can anybody help me with figuring out what could possible be wrong ?</p>
  
  <p>I have double checked the headers, hence i am sure that I it's something with the configuration or Jackson's support for unmarshalling to HashMap. Thanks for your time.</p>