title: Problem with Spring Boot Camel application
body: <p>I am still very new to using Apache Camel and am trying to adapt an example provided by someone (<a href="https://www.javainuse.com/camel/camel-consume-rest" rel="nofollow noreferrer">https://www.javainuse.com/camel/camel-consume-rest</a>) to essentially do the same thing the original application does, except by using a combination of Spring Boot and Camel with XML route configuration.</p>
  
  <p>I downloaded the original application code (both the Camel consumer and the HTTP server) and got those to run and execute properly very easily.</p>
  
  <p>Now, I want to modify the application a little so that Spring Boot is used to do all the behind-the-scenes configuration, and use the XML DSL to configure the Camel routes. The original Camel consumer application does not use Spring at all.</p>
  
  <p>I made the changes that seemed to make sense, but cannot get the application to run. I get the following exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(Ljava/lang/Class;Ljava/lang/ClassLoader;)Ljava/util/List; from class org.springframework.boot.SpringApplication
      at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418)
      at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:412)
      at org.springframework.boot.SpringApplication.&lt;init&gt;(SpringApplication.java:268)
      at org.springframework.boot.SpringApplication.&lt;init&gt;(SpringApplication.java:249)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
      at org.test.ApplicationMain.main(ApplicationMain.java:12)
  </code></pre>
  
  <p>I do not understand what it's complaining about. I'm including resources below so that people can look at what I'm doing. I apologize in advance for the amount of code.</p>
  
  <p>ApplicationMain.java:</p>
  
  <pre><code>@SpringBootApplication
  @ImportResource("classpath:camel-context.xml")
  public class ApplicationMain {
    public static void main(String[] args) {
      SpringApplication.run(ApplicationMain.class, args);
    }
  }
  </code></pre>
  
  <p>Configurer.java:</p>
  
  <pre><code>@Configuration
  @ComponentScan("org.test")
  public class Configurer {
    @Bean
    public MyProcessor myProcessor() {
      return new MyProcessor();
    }
  }
  </code></pre>
  
  <p>application.yml:</p>
  
  <pre><code>---
  camel:
    springboot:
      name: CamelConsumer
      main-run-controller: true
  </code></pre>
  
  <p>camel-context.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"&gt;
  
    &lt;import resource="classpath:routes/routes.xml" /&gt;
  
    &lt;camelContext id="camel-context" xmlns="http://camel.apache.org/schema/spring"&gt;
      &lt;routeContextRef ref="routes" /&gt;
    &lt;/camelContext&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>routes/routes.xml:</p>
  
  <p><strong>Note</strong>: I do not know whether I'm using the correct syntax for the elements in the route definition below. I'm trying to adapt it from the original, which was done in Java DSL. I'm also not sure whether or not I need the processor bean definition, since I also have the bean defined in the Configurer above.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"&gt;
  
    &lt;bean id="myProcessor" class="org.test.processor.MyProcessor" /&gt;
  
    &lt;routeContext id="routes" xmlns="http://camel.apache.org/schema/spring"&gt;
      &lt;route id="httpTest"&gt;
        &lt;from uri="file:C:/inboxREST?noop=true" /&gt;
        &lt;setHeader headerName="HTTP_METHOD"&gt;
          &lt;simple&gt;GET&lt;/simple&gt;
        &lt;/setHeader&gt;
        &lt;to uri="http://localhost:8080/employee?id=5" /&gt;
        &lt;process ref="myProcessor" /&gt;
      &lt;/route&gt;
    &lt;/routeContext&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>MyProcessor.java:</p>
  
  <pre><code>public class MyProcessor implements Processor {
    public MyProcessor() {
    }
    public void process(Exchange exchange) throws Exception {
      System.out.println(exchange.getIn().getBody(String.class));
    }
  }
  </code></pre>
  
  <p>pom.xml:</p>
  
  <p><strong>Note</strong>: You may notice a mix of Spring Boot Camel starters as well as Camel dependencies for Camel components (like HTTP). It's not clear to me which of these I actually need. Do the Spring Boot starters remove the need to include Camel component dependencies?</p>
  
  <pre><code>&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;com.javainuse&lt;/groupId&gt;
    &lt;artifactId&gt;apache-camel-consume&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
    &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.1.6.RELEASE&lt;/version&gt;
      &lt;relativePath /&gt;
    &lt;/parent&gt;
  
    &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  
      &lt;apache-camel-springboot.version&gt;3.1.0&lt;/apache-camel-springboot.version&gt;
      &lt;apache-camel.version&gt;3.1.0&lt;/apache-camel.version&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
  
      &lt;!-- Camel BOM --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.camel.springboot&lt;/groupId&gt;
        &lt;artifactId&gt;camel-spring-boot-dependencies&lt;/artifactId&gt;
        &lt;version&gt;${apache-camel-springboot.version}&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&gt;
        &lt;scope&gt;import&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Camel Starter --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.camel.springboot&lt;/groupId&gt;
        &lt;artifactId&gt;camel-spring-boot-starter&lt;/artifactId&gt;
        &lt;version&gt;${apache-camel-springboot.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.camel.springboot&lt;/groupId&gt;
        &lt;artifactId&gt;camel-spring-boot&lt;/artifactId&gt;
        &lt;version&gt;${apache-camel-springboot.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Camel HTTP --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
        &lt;artifactId&gt;camel-http&lt;/artifactId&gt;
        &lt;version&gt;${apache-camel.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.camel.springboot&lt;/groupId&gt;
        &lt;artifactId&gt;camel-http-starter&lt;/artifactId&gt;
        &lt;version&gt;${apache-camel-springboot.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Camel Jackson --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.camel.springboot&lt;/groupId&gt;
        &lt;artifactId&gt;camel-jackson-starter&lt;/artifactId&gt;
        &lt;version&gt;${apache-camel-springboot.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring Boot --&gt;
  
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
        &lt;exclusions&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt;
          &lt;/exclusion&gt;
        &lt;/exclusions&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;exclusions&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
          &lt;/exclusion&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt;
          &lt;/exclusion&gt;
        &lt;/exclusions&gt;
      &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
  
    &lt;build&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;/plugin&gt;
  
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
          &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
          &lt;extensions&gt;true&lt;/extensions&gt;
          &lt;version&gt;2.4.0&lt;/version&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>