title: How can I successfully use the Jackson "ObjectMapper()" inside a "process()" method
body: <p><strong><em>PROBLEM: using Jackson's "ObjectMapper()" within the "process()" method causes an exception...</em></strong></p>
  
  <pre><code>public void process(org.apache.camel.Exchange exchange) throws IOException {
  
      //...this statement causes the exception...
      com.fasterxml.jackson.databind.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper();
      ...
  }
  </code></pre>
  
  <p><em>The exception is shown in the Jboss Fuse console...looks like this...</em></p>
  
  <pre><code>...
  
  2017-09-12 16:45:56,262 | INFO  | edhat-187/deploy | fileinstall                      | 9 - org.apache.felix.fileinstall - 3.5.0 | Installing bundle aaa.bbb.ccc.camelRest / 1.0.0
  2017-09-12 16:45:56,323 | WARN  | edhat-187/deploy | fileinstall                      | 9 - org.apache.felix.fileinstall - 3.5.0 | Error while starting bundle: file:/C:/tools/jboss-fuse-6.3.0.redhat-187/deploy/camelRest-1.jar
  org.osgi.framework.BundleException: Unresolved constraint in bundle aaa.bbb.ccc.camelRest [759]: Unable to resolve 759.0: missing requirement [759.0] osgi.wiring.package; (&amp;(osgi.wiring.package=com.fasterxml.jackson.databind)(version&gt;=2.7.0)(!(version&gt;=3.0.0)))
      at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4002)[org.apache.felix.framework-4.4.1.jar:]
      at org.apache.felix.framework.Felix.startBundle(Felix.java:2045)[org.apache.felix.framework-4.4.1.jar:]
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)[org.apache.felix.framework-4.4.1.jar:]
      at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[9:org.apache.felix.fileinstall:3.5.0]
      at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[9:org.apache.felix.fileinstall:3.5.0]
      at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:509)[9:org.apache.felix.fileinstall:3.5.0]
      at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[9:org.apache.felix.fileinstall:3.5.0]
      at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[9:org.apache.felix.fileinstall:3.5.0]
  
  ...
  </code></pre>
  
  <p><strong><em>QUESTION:</em></strong>
  <em>How can I successfully use the Jackson "ObjectMapper()" inside a "process()" method, i.e., to convert a map into json?</em></p>
  
  <hr>
  
  <hr>
  
  <p><strong><em>To provide context, below is the info on this simple application/bundle</em></strong></p>
  
  <p><strong>aaa.bbb.ccc.CamelRestRoutes.java</strong></p>
  
  <pre><code>package aaa.bbb.ccc;
  
  import org.apache.camel.Exchange;
  import org.apache.camel.builder.RouteBuilder;
  import org.apache.camel.cdi.ContextName;
  
  @ContextName("rest-dsl")
  public class CamelRestRoutes extends RouteBuilder {
  
      public CamelRestRoutes() {
      }
  
      private final org.apache.camel.Processor proc1 = new Processor1();
  
      int notificationTime = 60;
      int overlapTime = 5;    
      String codeListString = "AA,BB";
  
      @Override
      public void configure() throws Exception {
  
      String fromURL = "http://localhost:7001/jaxrsRestService/service/getAll"; 
  
      from("timer://foo?fixedRate=true&amp;period=" + 5000) //5 seconds... do we need to make this a system property (like notification service)???....
          .setBody(constant(codeListString))            
          .to("direct:thingB");
  
      from("direct:thingB")
          .split().tokenize(",")
          .to("direct:thingC");       
  
      from("direct:thingC")
          .setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.GET))
          .to("netty4-http:http://localhost:7001/jaxrsRestService/service/getAll/")
          .to("direct:thingD");
  
      from("direct:thingD")
          .split()
          .jsonpath("$.container[*]")
          .streaming()
          .parallelProcessing()
          .process(proc1)
          .to("wmq:queue:mylocalqueue?jmsMessageType=Text&amp;exchangePattern=InOnly");
      }
  }
  </code></pre>
  
  <p><strong>aaa.bbb.ccc.Processor1.java</strong></p>
  
  <pre><code>package aaa.bbb.ccc;
  
  import java.io.IOException;
  import java.util.Map;
  
  public class Processor1 implements org.apache.camel.Processor {
  
      @Override
      public void process(org.apache.camel.Exchange exchange) throws IOException {
  
      //***this causes the exception***
      com.fasterxml.jackson.databind.ObjectMapper.ObjectMapper om = new com.fasterxml.jackson.databind.ObjectMapper.ObjectMapper();  &lt;== causes
  
      Map&lt;String, String&gt; map = (Map&lt;String, String&gt;) exchange.getIn().getBody();
  
      exchange.getIn().setBody(map.toString());
      }
  };
  </code></pre>
  
  <p><strong>camel-route.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
         xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
         xmlns:camel="http://camel.apache.org/schema/blueprint"
         xsi:schemaLocation="
           http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
           http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
           http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
           "&gt;
      &lt;camel:camelContext id="aaa.bbb.ccc.routing.poc" xmlns="http://camel.apache.org/schema/blueprint"&gt;
      &lt;packageScan&gt;
          &lt;package&gt;aaa.bbb.ccc&lt;/package&gt;
      &lt;/packageScan&gt;
      &lt;/camel:camelContext&gt;
  
      &lt;bean id="wmqcf" class="com.ibm.mq.jms.MQConnectionFactory"&gt;
      &lt;property name="hostName" value="localhost"/&gt;        
      &lt;property name="port" value="1414"/&gt;
      &lt;property name="queueManager" value="QM1"/&gt;     
      &lt;property name="channel" value="DEV.ADMIN.SVRCONN"/&gt;                     
      &lt;property name="transportType" value="1"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="wmqcfw"  class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"&gt;
      &lt;property name="targetConnectionFactory" ref="wmqcf" /&gt;
      &lt;property name="username" value="admin" /&gt;
      &lt;property name="password" value="passw0rd" /&gt;
      &lt;/bean&gt;  
  
      &lt;bean id="wmqcfg" class="org.apache.camel.component.jms.JmsConfiguration"&gt;
      &lt;property name="connectionFactory" ref="wmqcfw"/&gt;
      &lt;property name="concurrentConsumers" value="10"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="wmq" class="org.apache.camel.component.jms.JmsComponent"&gt;
      &lt;property name="configuration" ref="wmqcfg"/&gt;     
      &lt;/bean&gt;    
  &lt;/blueprint&gt;
  </code></pre>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;aaa.bbb.ccc&lt;/groupId&gt;
      &lt;artifactId&gt;camelRest&lt;/artifactId&gt;
      &lt;version&gt;1&lt;/version&gt;
      &lt;packaging&gt;bundle&lt;/packaging&gt;
      &lt;name&gt;camelRest&lt;/name&gt;
      &lt;description&gt;camelRest&lt;/description&gt;
  
      &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;skipTests&gt;true&lt;/skipTests&gt;
      &lt;mq.version&gt;8.0.0.7&lt;/mq.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
          &lt;version&gt;1.7.25&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;               
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;1.7.25&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;               
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-core&lt;/artifactId&gt;
          &lt;version&gt;2.17.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;     
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-cdi&lt;/artifactId&gt;
          &lt;version&gt;2.17.0&lt;/version&gt; 
          &lt;scope&gt;provided&lt;/scope&gt;                     
      &lt;/dependency&gt;    
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-netty4-http&lt;/artifactId&gt;
          &lt;version&gt;2.17.0&lt;/version&gt; 
          &lt;scope&gt;provided&lt;/scope&gt;                     
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-jackson&lt;/artifactId&gt;
          &lt;version&gt;2.17.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;               
      &lt;/dependency&gt;      
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-http4&lt;/artifactId&gt;
          &lt;version&gt;2.17.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;       
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-cxf&lt;/artifactId&gt;
          &lt;version&gt;2.17.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;              
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.ibm.mq&lt;/groupId&gt;
          &lt;artifactId&gt;allclient&lt;/artifactId&gt;
          &lt;version&gt;${mq.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;               
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.ibm.mq&lt;/groupId&gt;
          &lt;artifactId&gt;jms&lt;/artifactId&gt;
          &lt;version&gt;${mq.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
          &lt;artifactId&gt;camel-jsonpath&lt;/artifactId&gt;
          &lt;version&gt;2.17.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;                        
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
      &lt;finalName&gt;${project.artifactId}-${project.version}&lt;/finalName&gt;
  
      &lt;resources&gt;
          &lt;resource&gt;
          &lt;directory&gt;src/main/resources&lt;/directory&gt;
          &lt;filtering&gt;true&lt;/filtering&gt;
          &lt;/resource&gt;
      &lt;/resources&gt;
  
      &lt;plugins&gt;
  
          &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.1&lt;/version&gt;
          &lt;configuration&gt;
              &lt;source&gt;1.8&lt;/source&gt;
              &lt;target&gt;1.8&lt;/target&gt;
              &lt;showDeprecation&gt;true&lt;/showDeprecation&gt;
          &lt;/configuration&gt;
          &lt;/plugin&gt; 
  
          &lt;plugin&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;jaxb2-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.3&lt;/version&gt;
          &lt;executions&gt;
              &lt;execution&gt;
              &lt;id&gt;xjc&lt;/id&gt;
              &lt;goals&gt;
                  &lt;goal&gt;xjc&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;        
          &lt;configuration&gt;
              &lt;sources&gt;
              &lt;source&gt;src/main/resources/xsd/jaxrsRestService.xsd&lt;/source&gt;
              &lt;/sources&gt;
              &lt;packageName&gt;aaa.bbb.ccc.generated&lt;/packageName&gt;                    
              &lt;verbose default-value="false"&gt;${xjc.verbose}&lt;/verbose&gt;
          &lt;/configuration&gt;                
          &lt;/plugin&gt;              
  
          &lt;plugin&gt;
          &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
          &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.3.0&lt;/version&gt;
          &lt;extensions&gt;true&lt;/extensions&gt;
          &lt;configuration&gt;
              &lt;instructions&gt;
              &lt;Bundle-SymbolicName&gt;${project.groupId}.${project.artifactId}&lt;/Bundle-SymbolicName&gt;
              &lt;Export-Package&gt;aaa.bbb.ccc*&lt;/Export-Package&gt; 
              &lt;Export-Package&gt;aaa.bbb.ccc.generated*&lt;/Export-Package&gt;
              &lt;Import-Package&gt;*&lt;/Import-Package&gt;                                                                      
              &lt;/instructions&gt;
          &lt;/configuration&gt;
          &lt;/plugin&gt;             
      &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><strong><em>camel features installed</em></strong></p>
  
  <pre><code>JBossFuse:karaf@root&gt; features:list | grep "camel-" | grep "\[installed"
  [installed  ] [2.7.0                ] xml-specs-api                                 camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel                                         camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-core                                    camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-blueprint                               camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-spring                                  camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-bindy                                   camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-cdi                                     camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-csv                                     camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-cxf                                     camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-exec                                    camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-ftp                                     camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-http4                                   camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-jackson                                 camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-jacksonxml                              camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-jasypt                                  camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-jaxb                                    camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-jdbc                                    camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-jms                                     camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-jmx                                     camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-jsonpath                                camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-mail                                    camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-netty4                                  camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-netty4-http                             camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-ognl                                    camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-paxlogging                              camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-restlet                                 camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-rmi                                     camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-routebox                                camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-saxon                                   camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-script                                  camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-snmp                                    camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-spring-javaconfig                       camel-2.17.0.redhat-630187
  [installed  ] [2.17.0.redhat-630187 ] camel-xstream                                 camel-2.17.0.redhat-630187
  [installed  ] [1.2.0.redhat-630187  ] camel-amq                                     fabric-1.2.0.redhat-630187
  JBossFuse:karaf@root&gt;
  </code></pre>
  
  <p><strong><em>deploy directory containing IBM MQ osgi jars</em></strong></p>
  
  <pre><code>Directory of C:\tools\jboss-fuse-6.3.0.redhat-187\deploy
  
  09/13/2017  10:19 AM    &lt;DIR&gt;          .
  09/13/2017  10:19 AM    &lt;DIR&gt;          ..
  09/12/2017  05:10 PM            14,495 camelRest-1.jar
  06/29/2017  01:00 AM           159,649 com.ibm.mq.osgi.allclientprereqs_8.0.0.7.jar
  06/29/2017  01:00 AM         8,011,749 com.ibm.mq.osgi.allclient_8.0.0.7.jar
  06/29/2017  01:00 AM         4,088,715 com.ibm.mq.osgi.java_8.0.0.7.jar
  06/29/2017  01:00 AM           171,064 com.ibm.msg.client.osgi.commonservices.j2se_8.0.0.7.jar
  06/29/2017  01:00 AM            48,715 com.ibm.msg.client.osgi.jms.prereq_8.0.0.7.jar.DISABLE
  06/29/2017  01:00 AM           639,807 com.ibm.msg.client.osgi.jms_8.0.0.7.jar
  06/29/2017  01:00 AM           216,218 com.ibm.msg.client.osgi.nls_8.0.0.7.jar
  06/29/2017  01:00 AM           279,861 com.ibm.msg.client.osgi.wmq.nls_8.0.0.7.jar
  06/29/2017  01:00 AM            92,406 com.ibm.msg.client.osgi.wmq.prereq_8.0.0.7.jar
  06/29/2017  01:00 AM         7,963,226 com.ibm.msg.client.osgi.wmq_8.0.0.7.jar
  09/15/2016  04:19 AM               873 README
            12 File(s)     21,686,778 bytes
             2 Dir(s)  142,681,493,504 bytes free
  </code></pre>
  
  <p><strong><em>other environment info</em></strong></p>
  
  <pre><code>jdk1.8.0_131
  jboss-fuse-6.3.0.redhat-187
  WebLogic 12.2.1  (running the rest service)
  </code></pre>
  
  <p>Thank you for your help!</p>