title: RabbitMQ's "receiveAndConvert" thows a ClassCastException
body: <p>I am new to RabbitMQ and I am trying to "<code>receiveAndConvert</code>" to a custom type of mine: <code>Person.java</code>.</p>
  
  <p>Here is my <strong>producer</strong>:</p>
  
  <pre><code>public class Producer {
  
      public static void main(String[] args) {
          ApplicationContext context = new GenericXmlApplicationContext("classpath:/applicationContext.xml");
          AmqpTemplate template = context.getBean(AmqpTemplate.class);
          Person person = new Person();
          person.setAge(37);
          person.setName("Julien");
          template.convertAndSend("myqueue", person);
      }
  
  }
  </code></pre>
  
  <p>and here is my <strong>consumer</strong>:</p>
  
  <pre><code>public class Consumer {
  
      public static void main(String[] args) {
          ApplicationContext context = new GenericXmlApplicationContext("classpath:/applicationContext.xml");
          AmqpTemplate template = context.getBean(AmqpTemplate.class);
          Person me = (Person) template.receiveAndConvert("myqueue");
          System.out.println("Me: " + me.getName() + ":" + me.getAge());
      }
  
  }
  </code></pre>
  
  <p>My <strong>Person.java is just a POJO</strong> with a name and an age instance variables.</p>
  
  <p>I get a <strong>ClassCastException</strong> as follows:</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to trc.suivi.amqp.Person
      at trc.suivi.amqp.Consumer.main(Consumer.java:14)
  </code></pre>
  
  <p>Note that the Producer and Consumer classes are located in two different projects and I have copied/pasted the Person.java class over to the Consumer project.</p>
  
  <p>My <strong>config</strong> is as follows:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
      xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.1.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;
  
      &lt;rabbit:connection-factory id="connectionFactory" /&gt;
      &lt;rabbit:template id="amqpTemplate" connection-factory="connectionFactory" /&gt;
      &lt;rabbit:admin connection-factory="connectionFactory" /&gt;
      &lt;rabbit:queue name="myqueue" /&gt;
  
  &lt;/beans&gt;
  </code></pre>