title: Why Jackson2JsonMessageConverter convert List<String> to List<Object>
body: <p>I am working on Spring AMQP with RabbitMQ , I configured a <code>MessageConverter( Jackson2JsonMessageConverter)</code> with <code>ObjectMapper</code>. if I call <code>convertAndSend(,,,)</code> method from sender class by passing <code>HashMap&lt;String,Object&gt;</code> then <code>Receiver</code> class <code>handleMessage()</code> method successfully got the message of Type <code>HashMap</code> . But the problem is , this <code>HashMap</code> contain a <code>List</code> of string as <code>List&lt;String&gt;</code> . When I receive this <code>HashMap</code> in <code>Receiver</code> I tried to get <code>List&lt;String&gt;</code> via key but it giving an error <code>List&lt;Object&gt; can't cast Object list to string list</code> . This is my code of <code>Config</code> class , sender class and Receiver class</p>
  
  <pre><code>@Configuration
  public class RabbitMQConfig {
  
      @Autowired
      Environment environment;
  
      final static String paymentQueue = "mobily-payment-queue";
      final static String mailQueue = "mobily-mail-queue";
      final static String orderQueue = "mobily-order-queue";
      final static String deductProductQueue = "mobily-deduct-product-queue";
      @Bean
      public ConnectionFactory connectionFactory() {
          CachingConnectionFactory connectionFactory = new CachingConnectionFactory(environment.getRequiredProperty("rabbitmq.host"),Integer.parseInt(environment.getRequiredProperty("rabbitmq.port")));
          connectionFactory.setUsername(environment.getRequiredProperty("rabbitmq.user"));
          connectionFactory.setPassword(environment.getRequiredProperty("rabbitmq.pass"));
          return connectionFactory;
      }
  
      @Bean 
      public MessageConverter jsonMessageConverter() { 
          final Jackson2JsonMessageConverter converter = new Jackson2JsonMessageConverter(); 
  
  
          ObjectMapper mapper = new ObjectMapper();
          mapper.registerModule(new JodaModule());
          mapper.registerModule(new Hibernate4Module());
          mapper.setSerializationInclusion(Include.NON_NULL);
           converter.setJsonObjectMapper(mapper);
          return converter; 
       }
  
  
      @Bean
      public RabbitTemplate template(MessageConverter jsonMessageConverter) {
          RabbitTemplate template = new RabbitTemplate(connectionFactory());
          template.setMessageConverter(jsonMessageConverter);
          return template;
      }
  
      @Bean
      public DirectExchange direct() {
          return new DirectExchange("mobily.direct");
      }
  
          @Bean
          public Queue paymentQueue(){
              return new Queue(paymentQueue);
          }
  
          @Bean
          public Queue deductProductQueue() {
              return new Queue(deductProductQueue);
          }
  
          @Bean
          public Queue orderQueue() {
              return new Queue(orderQueue);
          }
  
          @Bean
          public Queue mailQueue(){
              return new Queue(mailQueue);
          }
  
          @Bean
          public Binding paymentBinding(DirectExchange direct, Queue paymentQueue) {
              return BindingBuilder.bind(paymentQueue).to(direct).with(environment.getRequiredProperty("rabbitmq.payment.key"));
          }
  
          @Bean
          public Binding deductProductBinding(DirectExchange direct, Queue deductProductQueue) {
              return BindingBuilder.bind(deductProductQueue).to(direct).with(environment.getRequiredProperty("rabbitmq.deduct.product.key"));
          }
  
          @Bean
          public Binding orderBinding(DirectExchange direct, Queue orderQueue) {
              return BindingBuilder.bind(orderQueue).to(direct).with(environment.getRequiredProperty("rabbitmq.order.key"));
          }
  
          @Bean
          public Binding mailBinding(DirectExchange direct, Queue mailQueue) {
              return BindingBuilder.bind(mailQueue).to(direct).with(environment.getRequiredProperty("rabbitmq.mail.key"));
          }
  
          /*@Bean
          Receiver receiver() {
              return new Receiver();
          }*/
  
          @Bean
          PaymentReceiver paymentReceiver(){
  
              return new PaymentReceiver();
          }
  
          @Bean
          DeductProductReceiver deductProductReceiver(){
  
              return new DeductProductReceiver();
          }
  
          @Bean
          OrderReceiver orderReceiver(){
              return new OrderReceiver();
          }
  
          @Bean
          MailReceiver mailReceiver(){
  
              return new MailReceiver();
          }
  
          @Bean
          SimpleMessageListenerContainer deductProductContainer(ConnectionFactory connectionFactory, MessageListenerAdapter deductProductListenerAdapter) {
              SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
              container.setConnectionFactory(connectionFactory);
              container.setQueueNames(deductProductQueue);
              container.setMessageListener(deductProductListenerAdapter);
              return container;
  
  
          }
  
          @Bean
          MessageListenerAdapter deductProductListenerAdapter(DeductProductReceiver deductProductReceiver,MessageConverter jsonMessageConverter) {
              return new MessageListenerAdapter(deductProductReceiver, jsonMessageConverter);
          }
  
          @Bean
          SimpleMessageListenerContainer paymentContainer(ConnectionFactory connectionFactory, MessageListenerAdapter paymentListenerAdapter) {
              SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
              container.setConnectionFactory(connectionFactory);
              container.setQueueNames(paymentQueue);
              container.setMessageListener(paymentListenerAdapter);
              return container;
  
  
          }
  
          @Bean
          MessageListenerAdapter paymentListenerAdapter(PaymentReceiver paymentReceiver,MessageConverter jsonMessageConverter) {
              return new MessageListenerAdapter(paymentReceiver,jsonMessageConverter );
          }
  
          @Bean
          SimpleMessageListenerContainer orderContainer(ConnectionFactory connectionFactory, MessageListenerAdapter orderListenerAdapter) {
              SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
              container.setConnectionFactory(connectionFactory);
              container.setQueueNames(orderQueue);
              container.setMessageListener(orderListenerAdapter);
              return container;
  
  
          }
  
          @Bean
          MessageListenerAdapter orderListenerAdapter(OrderReceiver orderReceiver,MessageConverter jsonMessageConverter) {
              return new MessageListenerAdapter(orderReceiver,jsonMessageConverter);
          }
  
          @Bean
          SimpleMessageListenerContainer mailContainer(ConnectionFactory connectionFactory, MessageListenerAdapter mailListenerAdapter) {
              SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
              container.setConnectionFactory(connectionFactory);
              container.setQueueNames(mailQueue);
              container.setMessageListener(mailListenerAdapter);
              return container;
  
  
          }
  
          @Bean
          MessageListenerAdapter mailListenerAdapter(MailReceiver mailReceiver,MessageConverter jsonMessageConverter) {
              return new MessageListenerAdapter(mailReceiver,jsonMessageConverter);
          }
  
  
  
  
  }
  </code></pre>
  
  <p>This is My sender class</p>
  
  <pre><code>HashMap&lt;String, Object&gt; mailMap=new HashMap&lt;String, Object&gt;();
  CustomerAccountUser customerAccountUser=customerAccountUserService.getCustomerAccountUserByUsername(customerAccountPayments.getCustomerName());
               ArrayList&lt;String&gt; emailAddress=new ArrayList&lt;String&gt;();
               emailAddress.add(customerAccountUser.getEmail());
   template.convertAndSend(direct.getName(),environment.getRequiredProperty("rabbitmq.mail.key"),mailMap);
  </code></pre>
  
  <p>This is My Receiver</p>
  
  <pre><code>public void handleMessage(HashMap&lt;String,Object&gt; mailMap){
  
      try{
          System.out.println("mail queue..................................." + mailMap);
          String s1=(String)mailMap.get("subject");
          String s2=(String)mailMap.get("body");
          List&lt;String&gt; list=(List&lt;String&gt;)mailMap.get("emailAddress");
      }
  }
  </code></pre>
  
  <p>This the error </p>
  
  <pre><code>    e2016-05-24 17:02:47 ERROR stderr:71 - java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
  2016-05-24 17:02:47 ERROR stderr:71 -   at com.mobily.service.EmailService.sendEmail(EmailService.java:24)
  2016-05-24 17:02:47 INFO  stdout:71 -     values
  2016-05-24 17:02:47 ERROR stderr:71 -   at com.mobily.customer.rabbitmq.reciever.MailReceiver.handleMessage(MailReceiver.java:27)
  2016-05-24 17:02:47 ERROR stderr:71 -   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  2016-05-24 17:02:47 ERROR stderr:71 -   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  2016-05-24 17:02:47 ERROR stderr:71 -   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  2016-05-24 17:02:47 ERROR stderr:71 -   at java.lang.reflect.Method.invoke(Method.java:497)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:387)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:298)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:757)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:680)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$001(SimpleMessageListenerContainer.java:93)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$1.invokeListener(SimpleMessageListenerContainer.java:183)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:1358)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:661)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:1102)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:1086)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$1100(SimpleMessageListenerContainer.java:93)
  2016-05-24 17:02:47 ERROR stderr:71 -   at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1203)`enter code here`e
  </code></pre>