title: ActiveMq throws MessageConversionException: Failed to resolve type id when sending an object
body: <p>I am trying to use ActiveMQ in my two spring boot applications, where I want to enqueue an Object in the first app and dequeue it from the second app.</p>
  
  <p>but I have this error </p>
  
  <pre><code>org.springframework.jms.listener.adapter.ListenerExecutionFailedException: Listener method 'public void com.javasampleapproach.activemq.jms.consumer.JmsReplyConsumer.receive(com.javasampleapproach.activemq.model.PlaceForm)' threw exception; nested exception is org.springframework.jms.support.converter.MessageConversionException: Failed to resolve type id [org.sc.oauth2.resource.server.model.PlaceForm]; nested exception is java.lang.ClassNotFoundException: org.sc.oauth2.resource.server.model.PlaceForm
  </code></pre>
  
  <p>my model PlaceForm (Object which I want to enqueue) is same in the two apps :</p>
  
  <pre><code>@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class,property="@id", scope = PlaceForm.class)
  public class PlaceForm  implements Serializable{
      private Long id;
      private String Name;
      private double X;
      private double Y;
      private String Description;
      private Long place_type_id;
      public Long getId() {
          return id;
      }
      public void setId(Long id) {
          this.id = id;
      }
      public String getName() {
          return Name;
      }
      public void setName(String name) {
          Name = name;
      }
      public double getX() {
          return X;
      }
      public void setX(double x) {
          X = x;
      }
      public double getY() {
          return Y;
      }
      public void setY(double y) {
          Y = y;
      }
      public String getDescription() {
          return Description;
      }
      public void setDescription(String description) {
          Description = description;
      }
      public Long getPlace_type_id() {
          return place_type_id;
      }
      public void setPlace_type_id(Long place_type_id) {
          this.place_type_id = place_type_id;
      }
  }
  </code></pre>
  
  <p>and the configuration is the same in tow apps too:</p>
  
  <pre><code>@Configuration
  public class ActiveMqConnectionFactoryConfig {
  
      @Value("${jsa.activemq.broker.url}")
      String brokerUrl;
  
      @Value("${jsa.activemq.borker.username}")
      String userName;
  
      @Value("${jsa.activemq.borker.password}")
      String password;
  
      /*
       * Initial ConnectionFactory
       */
      @Bean
      public ConnectionFactory connectionFactory(){
          ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
          connectionFactory.setBrokerURL(brokerUrl);
          connectionFactory.setUserName(userName);
          connectionFactory.setPassword(password);
          return connectionFactory;
      }
  
      @Bean // Serialize message content to json using TextMessage
      public MessageConverter jacksonJmsMessageConverter() {
          MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
          converter.setTargetType(MessageType.TEXT);
          converter.setTypeIdPropertyName("_type");
          return converter;
      }
  
      /*
       * Used for Receiving Message
       */
      @Bean
      public JmsListenerContainerFactory&lt;?&gt; jsaFactory(ConnectionFactory connectionFactory,
                                                      DefaultJmsListenerContainerFactoryConfigurer configurer) {
          DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
          factory.setMessageConverter(jacksonJmsMessageConverter());
          configurer.configure(factory, connectionFactory);
          return factory;
      }
  
      /*
       * Used for Sending Messages.
       */
      @Bean
      public JmsTemplate jmsTemplate(){
          JmsTemplate template = new JmsTemplate();
          template.setMessageConverter(jacksonJmsMessageConverter());
          template.setConnectionFactory(connectionFactory());
          return template;
      }
  }
  </code></pre>
  
  <p>In the sender app I used: </p>
  
  <pre><code>@Component
  public class JmsProducer {
  
      @Autowired
      JmsTemplate jmsTemplate;
  
      @Value("${jsa.activemq.queue.producer}")
      String queue;
  
      public void send(PlaceForm product) {
          jmsTemplate.convertAndSend(queue, product);
      }
  }
  </code></pre>
  
  <p>where Application.properties is </p>
  
  <pre><code>jsa.activemq.broker.url=tcp://localhost:61616
  jsa.activemq.borker.username=admin
  jsa.activemq.borker.password=admin
  
  jsa.activemq.queue.producer=jsa-queue-1
  jsa.activemq.queue.consumer=jsa-queue-2
  </code></pre>
  
  <p>and the dependencies are </p>
  
  <pre><code>&lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
              &lt;version&gt;3.5&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-activemq&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
              &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
  
          &lt;/dependency&gt;
  
  
      &lt;/dependencies&gt;
  </code></pre>
  
  <p>and in the reciver app I used:</p>
  
  <pre><code>@Component
  public class JmsReplyConsumer {
  
      @Autowired
      PlaceService placeservice;
      @Autowired
      JmsProducer jms;
      @JmsListener(destination = "${jsa.activemq.queue.listen}", containerFactory = "jsaFactory")
      @SendTo("${jsa.activemq.queue.sendto}")    
      public void receive(PlaceForm s)  {
                     System.out.println("Done");
      }
  }
  </code></pre>
  
  <p>where Application.properties is </p>
  
  <pre><code>jsa.activemq.broker.url=tcp://localhost:61616
  jsa.activemq.borker.username=admin
  jsa.activemq.borker.password=admin
  jsa.activemq.queue.listen=jsa-queue-1
  jsa.activemq.queue.sendto=jsa-queue-2
  jsa.activemq.queue.send2=jsa-queue-3
  </code></pre>
  
  <p>and the dependencies are </p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-activemq&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
          &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
  
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
          &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
          &lt;version&gt;3.5&lt;/version&gt;
      &lt;/dependency&gt;
  
  
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>the "Done" is not printed and the full error is :</p>
  
  <pre><code>org.springframework.jms.listener.adapter.ListenerExecutionFailedException: Listener method 'public void com.javasampleapproach.activemq.jms.consumer.JmsReplyConsumer.receive(com.javasampleapproach.activemq.model.PlaceForm)' threw exception; nested exception is org.springframework.jms.support.converter.MessageConversionException: Failed to resolve type id [org.sc.oauth2.resource.server.model.PlaceForm]; nested exception is java.lang.ClassNotFoundException: org.sc.oauth2.resource.server.model.PlaceForm
      at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:112) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:69) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) [spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) [spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) [spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) [spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) [spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at java.lang.Thread.run(Thread.java:745) [na:1.8.0_73]
  Caused by: org.springframework.jms.support.converter.MessageConversionException: Failed to resolve type id [org.sc.oauth2.resource.server.model.PlaceForm]; nested exception is java.lang.ClassNotFoundException: org.sc.oauth2.resource.server.model.PlaceForm
      at org.springframework.jms.support.converter.MappingJackson2MessageConverter.getJavaTypeForMessage(MappingJackson2MessageConverter.java:507) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.support.converter.MappingJackson2MessageConverter.fromMessage(MappingJackson2MessageConverter.java:228) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener.extractMessage(AbstractAdaptableMessageListener.java:222) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener$MessagingMessageConverterAdapter.extractPayload(AbstractAdaptableMessageListener.java:442) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener$MessagingMessageConverterAdapter$LazyResolutionMessage.unwrapPayload(AbstractAdaptableMessageListener.java:506) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener$MessagingMessageConverterAdapter$LazyResolutionMessage.getPayload(AbstractAdaptableMessageListener.java:489) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver.resolveArgument(PayloadArgumentResolver.java:113) ~[spring-messaging-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:112) ~[spring-messaging-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:135) ~[spring-messaging-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:107) ~[spring-messaging-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:104) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      ... 10 common frames omitted
  Caused by: java.lang.ClassNotFoundException: org.sc.oauth2.resource.server.model.PlaceForm
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_73]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_73]
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_73]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_73]
      at org.springframework.boot.devtools.restart.classloader.RestartClassLoader.loadClass(RestartClassLoader.java:151) ~[spring-boot-devtools-1.5.8.RELEASE.jar:1.5.8.RELEASE]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_73]
      at org.springframework.util.ClassUtils.forName(ClassUtils.java:250) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      at org.springframework.jms.support.converter.MappingJackson2MessageConverter.getJavaTypeForMessage(MappingJackson2MessageConverter.java:503) ~[spring-jms-4.3.12.RELEASE.jar:4.3.12.RELEASE]
      ... 20 common frames omitted
  </code></pre>
  
  <p>can any body help me please???</p>