title: Spring Boot Camel JPA No local transaction to join
body: <p>I am using</p>
  
  <pre><code>Spring Boot 1.5.10.RELEASE
  Camel 2.21.1
  Java 1.8
  </code></pre>
  
  <p>My application</p>
  
  <pre><code>@SpringBootApplication
  @ImportResource({"classpath:my-webservice.xml", "classpath:my-camel.xml"})
  public class CamelCXFApplication extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
          SpringApplication.run(CamelCXFApplication.class, args);
      }
  
      @Bean
      ServletRegistrationBean servletRegistrationBean() {
          ServletRegistrationBean servlet = new ServletRegistrationBean(new CamelHttpTransportServlet(), "/camel-rest-jpa/*");
          servlet.setName("CamelServlet");
          return servlet;
      }
  }
  </code></pre>
  
  <p>My route</p>
  
  <pre><code>@Component
  public class RestAPI extends RouteBuilder {
  
      @Override
      public void configure() {
          restConfiguration().contextPath("/camel-rest-jpa").apiContextPath("/api-doc")
                  .apiProperty("api.title", "Camel REST API")
                  .apiProperty("api.version", "1.0")
                  .apiProperty("cors", "true")
                  .apiContextRouteId("doc-api")
                  .bindingMode(RestBindingMode.json);
  
  
          rest("/books").description("Books REST service")
                  .get("/").description("The list of all the books")
                  .route().routeId("books-api")
                  .bean(Database.class, "findBooks")
                  .endRest()
                  .get("order/{id}").description("Details of an order by id")
                  .route().routeId("order-api")
                  .bean(Database.class, "findOrder(${header.id})");
  
  
      }
  }
  </code></pre>
  
  <p>My BackendRoute</p>
  
  <pre><code>@Component
  public class Backend extends RouteBuilder {
  
      @Override
      public void configure() {
  
  
          // A first route generates some orders and queue them in DB
          from("timer:new-order?delay=1s&amp;period={{example.generateOrderPeriod:2s}}")
                  .routeId("generate-order")
                  .bean("orderService", "generateOrder")
                  .to("jpa:org.apache.jms.example.spring.boot.rest.jpa.Order")
                  .log("Inserted new order ${body.id}");
  
          // A second route polls the DB for new orders and processes them
          from("jpa:org.apache.jms.example.spring.boot.rest.jpa.Order"
                  + "?consumer.namedQuery=new-orders"
                  + "&amp;consumer.delay={{example.processOrderPeriod:5s}}"
                  + "&amp;consumeDelete=false")
                  .routeId("process-order")
                  .log("Processed order #id ${body.id} with ${body.amount} copies of the «${body.book.description}» book");
  
      }
  }
  </code></pre>
  
  <p>Maven</p>
  
  <pre><code>&lt;dependencies&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;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-spring-boot-starter&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
              &lt;artifactId&gt;activemq-pool&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-jms-starter&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-jms&lt;/artifactId&gt;
              &lt;version&gt;${camel.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-servlet-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-web&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.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-spring-boot-starter-jaxws&lt;/artifactId&gt;
              &lt;version&gt;3.1.12&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
              &lt;artifactId&gt;cxf-rt-features-logging&lt;/artifactId&gt;
              &lt;version&gt;3.1.12&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-test-spring&lt;/artifactId&gt;
              &lt;version&gt;${camel.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-jackson-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-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-jpa-starter&lt;/artifactId&gt;
              &lt;version&gt;${camel.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-csv&lt;/artifactId&gt;
              &lt;version&gt;${camel.version}&lt;/version&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;${camel.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-swagger-java-starter&lt;/artifactId&gt;
              &lt;version&gt;${camel.version}&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                      &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
              &lt;artifactId&gt;camel-servlet&lt;/artifactId&gt;
              &lt;version&gt;${camel.version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>
  
  <p>I am getting error</p>
  
  <pre><code>2018-06-25 14:44:47.460  WARN 13696 --- [mer://new-order] o.a.camel.component.timer.TimerConsumer  : Error processing exchange. Exchange[ID-IZeno-NB1048-1529912673553-0-5]. Caused by: [javax.persistence.TransactionRequiredException - No local transaction to join]
  
  javax.persistence.TransactionRequiredException: No local transaction to join
      at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.doJoinTransaction(ExtendedEntityManagerCreator.java:388) ~[spring-orm-4.3.14.RELEASE.jar:4.3.14.RELEASE]
      at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:330) ~[spring-orm-4.3.14.RELEASE.jar:4.3.14.RELEASE]
      at com.sun.proxy.$Proxy121.joinTransaction(Unknown Source) ~[na:na]
      at org.apache.camel.component.jpa.JpaProducer$2.doInTransaction(JpaProducer.java:213) ~[camel-jpa-2.21.1.jar:2.21.1]
      at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.3.14.RELEASE.jar:4.3.14.RELEASE]
      at org.apache.camel.component.jpa.JpaProducer.processEntity(JpaProducer.java:210) ~[camel-jpa-2.21.1.jar:2.21.1]
      at org.apache.camel.component.jpa.JpaProducer.process(JpaProducer.java:162) ~[camel-jpa-2.21.1.jar:2.21.1]
      at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) ~[camel-core-2.21.1.jar:2.21.1]
      at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148) ~[camel-core-2.21.1.jar:2.21.1]
      at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) ~[camel-core-2.21.1.jar:2.21.1]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.21.1.jar:2.21.1]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) ~[camel-core-2.21.1.jar:2.21.1]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) ~[camel-core-2.21.1.jar:2.21.1]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.21.1.jar:2.21.1]
      at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:197) [camel-core-2.21.1.jar:2.21.1]
      at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:79) [camel-core-2.21.1.jar:2.21.1]
      at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_161]
      at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_161]
  </code></pre>
  
  <p>I am following the sample from <code>https://github.com/apache/camel/tree/master/examples/camel-example-spring-boot-rest-jpa</code> however I am not using Spring Boot 2.0.3, I am using 1.5.10.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I realized I have one <code>JmsTransactionManager</code></p>
  
  <pre><code>@Bean
      public JmsTransactionManager jmsTransactionManager(final ConnectionFactory connectionFactory) {
          JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
          jmsTransactionManager.setConnectionFactory(connectionFactory);
          return jmsTransactionManager;
      }
  </code></pre>
  
  <p>Do I need to define additional transactionManager for Jpa ? What else is required ?</p>