title: ClassNotFound Exception Occured while consuming JMS ObjectMessage
body: <p>I am consuming a JMS <code>ObjectMessage</code> through a listener written in Spring Boot. I am sending the <code>ObjectMessage</code> through my Camel application to ActiveMQ queue and I am listening to the queue from my listener class in my Spring Boot application. </p>
  
  <p>Code: </p>
  
  <pre class="lang-java prettyprint-override"><code>final BindyCsvDataFormat bindy = new BindyCsvDataFormat(EquityFeeds.class);
  ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
  CamelContext _ctx = new DefaultCamelContext(); 
  _ctx.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
  _ctx.addRoutes(new RouteBuilder() {
  
      public void configure() throws Exception {
          from("file:src/main/resources?fileName=data.csv")               
              .unmarshal(bindy)
              .split(body())
              .streaming().to("jms:queue:javaobjects.upstream.queue");
      }
  });
  </code></pre>
  
  <p>Here is my POJO class <code>EquityFeeds</code>: </p>
  
  <pre class="lang-java prettyprint-override"><code>@CsvRecord(separator = ",",skipFirstLine = true)
  public class EquityFeeds implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @DataField(pos = 1) 
      private String externalTransactionId;
  
      @DataField(pos = 2)
      private String clientId;
  
      // other fields and getters setters
      ...
  </code></pre>
  
  <p>In ActiveMQ queue I am receiving the message as: </p>
  
  <pre><code>camelproject.EquityFeeds@1665425
  </code></pre>
  
  <p>My JMS listener in Spring Boot: </p>
  
  <pre class="lang-java prettyprint-override"><code>@JmsListener(destination = "javaobjects.upstream.queue")
  public void capitalIQProcessor(final Message objectMessage) throws JMSException {
      Object messageData = null;
  
      if(objectMessage instanceof ObjectMessage) {
          ObjectMessage objMessage = (ObjectMessage) objectMessage;
          System.out.println("Starting Object Message.");
  
          Object object = objMessage.getObject();
  
          EquityFeeds equityFeeds = (EquityFeeds) object;
  
          System.out.println("Object: "+equityFeeds.toString());
      }    
  }
  </code></pre>
  
  <p>I am getting an Exception @ line <code>Object object = objMessage.getObject();</code>: </p>
  
  <pre><code>capitalIQProcessor(javax.jms.Message) throws javax.jms.JMSException' threw exception; nested exception is javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: camelproject.EquityFeeds. Caused by: javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: camelproject.EquityFeeds. Caused by: java.lang.ClassNotFoundException: camelproject.EquityFeeds
  </code></pre>
  
  <p>Through Stack Overflow and other posts on the net I made the following changes: </p>
  
  <ol>
  <li><p>I made the changes to <code>wrapper.conf</code> (apache-activemq-5.15.11-bin\apache-activemq-5.15.11\bin\win64)</p>
  
  <ol>
  <li>Added then entry: 
  <code>wrapper.java.classpath.3=C:\Users\sidbharg\eclipse-workspace\Sid\target\camelproject-0.0.1-SNAPSHOT.jar</code>
  This is the location of the .jar file where I have my POJO (EquityFeeds).</li>
  <li>Also added the entry: 
  <code>wrapper.java.additional.13=-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*"</code></li>
  </ol></li>
  <li><p>In My Consumer code I also added <code>activeMQConnectionFactory.setTrustAllPackages(true);</code>:</p></li>
  </ol>
  
  <pre class="lang-java prettyprint-override"><code>public ActiveMQConnectionFactory activeMQConnectionFactory() {
          ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
          activeMQConnectionFactory.setBrokerURL(brokerURL);
          activeMQConnectionFactory.setTrustAllPackages(true);
          return activeMQConnectionFactory;
  }
  </code></pre>
  
  <p>Now what is the issue? Why its giving me the exception. Where I am going wrong? Is there anything which I have forgotten and is needed to be added? </p>