Problem with Spring Boot Camel application

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Spring Boot Camel application

Gagnon, Joseph - 0553 - MITLL
Hello,

I am still very new to using Apache Camel and am trying to adapt an example provided by someone (https://www.javainuse.com/camel/camel-consume-rest) to essentially do the same thing the original application does, except by using a combination of Spring Boot and Camel with XML route configuration.

I downloaded the original application code (both the Camel consumer and the HTTP server) and got those to run and execute properly very easily.

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.

I made the changes that seemed to make sense, but cannot get the application to run. I get the following exception:

     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.<init>(SpringApplication.java:268)
           at org.springframework.boot.SpringApplication.<init>(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)

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.

ApplicationMain.java:

     @SpringBootApplication
     @ImportResource("classpath:camel-context.xml")
     public class ApplicationMain {
       public static void main(String[] args) {
           SpringApplication.run(ApplicationMain.class, args);
       }
     }

Configurer.java:

     @Configuration
     @ComponentScan("org.test")
     public class Configurer {
       @Bean
       public MyProcessor myProcessor() {
           return new MyProcessor();
       }
     }

application.yml:

     ---
     camel:
       springboot:
           name: CamelConsumer
           main-run-controller: true

camel-context.xml:

     <?xml version="1.0" encoding="UTF-8"?>
     <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">

       <import resource="classpath:routes/routes.xml" />

       <camelContext id="camel-context" xmlns="http://camel.apache.org/schema/spring">
           <routeContextRef ref="routes" />
       </camelContext>
     </beans>

routes/routes.xml:

**Note**: 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.

     <?xml version="1.0" encoding="UTF-8"?>
     <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">

       <bean id="myProcessor" class="org.test.processor.MyProcessor" />

       <routeContext id="routes" xmlns="http://camel.apache.org/schema/spring">
           <route id="httpTest">
             <from uri="file:C:/inboxREST?noop=true" />
             <setHeader headerName="HTTP_METHOD">
                <simple>GET</simple>
             </setHeader>
             <to uri="http://localhost:8080/employee?id=5" />
             <process ref="myProcessor" />
           </route>
       </routeContext>
     </beans>

MyProcessor.java:

     public class MyProcessor implements Processor {
       public MyProcessor() {
       }
       public void process(Exchange exchange) throws Exception {
          System.out.println(exchange.getIn().getBody(String.class));
       }
     }

pom.xml:

**Note**: 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?

     <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">
       <modelVersion>4.0.0</modelVersion>

       <groupId>com.javainuse</groupId>
       <artifactId>apache-camel-consume</artifactId>
       <version>0.0.1-SNAPSHOT</version>

       <parent>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-parent</artifactId>
           <version>2.1.6.RELEASE</version>
           <relativePath />
       </parent>

       <properties>
           <java.version>1.8</java.version>

           <apache-camel-springboot.version>3.1.0</apache-camel-springboot.version>
           <apache-camel.version>3.1.0</apache-camel.version>
       </properties>

       <dependencies>

           <!-- Camel BOM -->
           <dependency>
             <groupId>org.apache.camel.springboot</groupId>
             <artifactId>camel-spring-boot-dependencies</artifactId>
             <version>${apache-camel-springboot.version}</version>
             <type>pom</type>
             <scope>import</scope>
           </dependency>

           <!-- Camel Starter -->
           <dependency>
             <groupId>org.apache.camel.springboot</groupId>
             <artifactId>camel-spring-boot-starter</artifactId>
             <version>${apache-camel-springboot.version}</version>
           </dependency>

           <dependency>
             <groupId>org.apache.camel.springboot</groupId>
             <artifactId>camel-spring-boot</artifactId>
             <version>${apache-camel-springboot.version}</version>
           </dependency>

           <!-- Camel HTTP -->
           <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-http</artifactId>
             <version>${apache-camel.version}</version>
           </dependency>

           <dependency>
             <groupId>org.apache.camel.springboot</groupId>
             <artifactId>camel-http-starter</artifactId>
             <version>${apache-camel-springboot.version}</version>
           </dependency>

           <!-- Camel Jackson -->
           <dependency>
             <groupId>org.apache.camel.springboot</groupId>
             <artifactId>camel-jackson-starter</artifactId>
             <version>${apache-camel-springboot.version}</version>
           </dependency>

           <!-- Spring Boot -->

           <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter</artifactId>
             <exclusions>
                <exclusion>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
             </exclusions>
           </dependency>

           <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
             <exclusions>
                <exclusion>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
                <exclusion>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
             </exclusions>
           </dependency>

       </dependencies>

       <build>
           <plugins>
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
             </plugin>

             <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <version>2.4.0</version>
             </plugin>
           </plugins>
       </build>

     </project>

Can anyone tell me what I'm doing wrong?

Thanks,
Joe Gagnon

Reply | Threaded
Open this post in threaded view
|

Re: Problem with Spring Boot Camel application

Alex Dettinger
Hi Joe,

  Maybe versions alignment, If I'm right mvn dependency:tree would show non
aligned version while you should have something like camel 3.1.0 / spring
5.2.3.RELEASE / spring boot 2.2.4.RELEASE.
  Checking other examples may help in this regard, they should be available
here
https://github.com/apache/camel-spring-boot/tree/camel-spring-boot-3.1.x/examples
.

Cheers,
Alex




On Wed, Apr 1, 2020 at 5:21 PM Gagnon, Joseph - 0553 - MITLL <
[hidden email]> wrote:

> Hello,
>
> I am still very new to using Apache Camel and am trying to adapt an
> example provided by someone (
> https://www.javainuse.com/camel/camel-consume-rest) to essentially do the
> same thing the original application does, except by using a combination of
> Spring Boot and Camel with XML route configuration.
>
> I downloaded the original application code (both the Camel consumer and
> the HTTP server) and got those to run and execute properly very easily.
>
> 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.
>
> I made the changes that seemed to make sense, but cannot get the
> application to run. I get the following exception:
>
>      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.<init>(SpringApplication.java:268)
>            at
> org.springframework.boot.SpringApplication.<init>(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)
>
> 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.
>
> ApplicationMain.java:
>
>      @SpringBootApplication
>      @ImportResource("classpath:camel-context.xml")
>      public class ApplicationMain {
>        public static void main(String[] args) {
>            SpringApplication.run(ApplicationMain.class, args);
>        }
>      }
>
> Configurer.java:
>
>      @Configuration
>      @ComponentScan("org.test")
>      public class Configurer {
>        @Bean
>        public MyProcessor myProcessor() {
>            return new MyProcessor();
>        }
>      }
>
> application.yml:
>
>      ---
>      camel:
>        springboot:
>            name: CamelConsumer
>            main-run-controller: true
>
> camel-context.xml:
>
>      <?xml version="1.0" encoding="UTF-8"?>
>      <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">
>
>        <import resource="classpath:routes/routes.xml" />
>
>        <camelContext id="camel-context" xmlns="
> http://camel.apache.org/schema/spring">
>            <routeContextRef ref="routes" />
>        </camelContext>
>      </beans>
>
> routes/routes.xml:
>
> **Note**: 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.
>
>      <?xml version="1.0" encoding="UTF-8"?>
>      <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">
>
>        <bean id="myProcessor" class="org.test.processor.MyProcessor" />
>
>        <routeContext id="routes" xmlns="
> http://camel.apache.org/schema/spring">
>            <route id="httpTest">
>              <from uri="file:C:/inboxREST?noop=true" />
>              <setHeader headerName="HTTP_METHOD">
>                 <simple>GET</simple>
>              </setHeader>
>              <to uri="http://localhost:8080/employee?id=5" />
>              <process ref="myProcessor" />
>            </route>
>        </routeContext>
>      </beans>
>
> MyProcessor.java:
>
>      public class MyProcessor implements Processor {
>        public MyProcessor() {
>        }
>        public void process(Exchange exchange) throws Exception {
>           System.out.println(exchange.getIn().getBody(String.class));
>        }
>      }
>
> pom.xml:
>
> **Note**: 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?
>
>      <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">
>        <modelVersion>4.0.0</modelVersion>
>
>        <groupId>com.javainuse</groupId>
>        <artifactId>apache-camel-consume</artifactId>
>        <version>0.0.1-SNAPSHOT</version>
>
>        <parent>
>            <groupId>org.springframework.boot</groupId>
>            <artifactId>spring-boot-starter-parent</artifactId>
>            <version>2.1.6.RELEASE</version>
>            <relativePath />
>        </parent>
>
>        <properties>
>            <java.version>1.8</java.version>
>
>
>  <apache-camel-springboot.version>3.1.0</apache-camel-springboot.version>
>            <apache-camel.version>3.1.0</apache-camel.version>
>        </properties>
>
>        <dependencies>
>
>            <!-- Camel BOM -->
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-spring-boot-dependencies</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>              <type>pom</type>
>              <scope>import</scope>
>            </dependency>
>
>            <!-- Camel Starter -->
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-spring-boot-starter</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>            </dependency>
>
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-spring-boot</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>            </dependency>
>
>            <!-- Camel HTTP -->
>            <dependency>
>              <groupId>org.apache.camel</groupId>
>              <artifactId>camel-http</artifactId>
>              <version>${apache-camel.version}</version>
>            </dependency>
>
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-http-starter</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>            </dependency>
>
>            <!-- Camel Jackson -->
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-jackson-starter</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>            </dependency>
>
>            <!-- Spring Boot -->
>
>            <dependency>
>              <groupId>org.springframework.boot</groupId>
>              <artifactId>spring-boot-starter</artifactId>
>              <exclusions>
>                 <exclusion>
>                   <groupId>org.springframework.boot</groupId>
>                   <artifactId>spring-boot-starter-logging</artifactId>
>                 </exclusion>
>              </exclusions>
>            </dependency>
>
>            <dependency>
>              <groupId>org.springframework.boot</groupId>
>              <artifactId>spring-boot-starter-web</artifactId>
>              <exclusions>
>                 <exclusion>
>                   <groupId>org.springframework.boot</groupId>
>                   <artifactId>spring-boot-starter-tomcat</artifactId>
>                 </exclusion>
>                 <exclusion>
>                   <groupId>org.springframework.boot</groupId>
>                   <artifactId>spring-boot-starter-logging</artifactId>
>                 </exclusion>
>              </exclusions>
>            </dependency>
>
>        </dependencies>
>
>        <build>
>            <plugins>
>              <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                 <version>3.1</version>
>              </plugin>
>
>              <plugin>
>                 <groupId>org.apache.felix</groupId>
>                 <artifactId>maven-bundle-plugin</artifactId>
>                 <extensions>true</extensions>
>                 <version>2.4.0</version>
>              </plugin>
>            </plugins>
>        </build>
>
>      </project>
>
> Can anyone tell me what I'm doing wrong?
>
> Thanks,
> Joe Gagnon
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Problem with Spring Boot Camel application

Gagnon, Joseph - 0553 - MITLL
Alex,

I think that's what the problem was. I eventually, cleared out my local maven repo (.m2/repository) and then also needed to remove jars from the eclipse project settings.

Once this was done and the project rebuilt, the problem was finally resolved.

My guess is that the original project that was basing my code on, which I had downloaded, built and run, pulled in the older dependencies, resulting in the conflict.

Thanks,
Joe

-----Original Message-----
From: Alex Dettinger <[hidden email]>
Sent: Thursday, April 2, 2020 3:51 AM
To: [hidden email]
Subject: Re: Problem with Spring Boot Camel application

Hi Joe,

  Maybe versions alignment, If I'm right mvn dependency:tree would show non aligned version while you should have something like camel 3.1.0 / spring 5.2.3.RELEASE / spring boot 2.2.4.RELEASE.
  Checking other examples may help in this regard, they should be available here https://github.com/apache/camel-spring-boot/tree/camel-spring-boot-3.1.x/examples
.

Cheers,
Alex




On Wed, Apr 1, 2020 at 5:21 PM Gagnon, Joseph - 0553 - MITLL < [hidden email]> wrote:

> Hello,
>
> I am still very new to using Apache Camel and am trying to adapt an
> example provided by someone (
> https://www.javainuse.com/camel/camel-consume-rest) to essentially do
> the same thing the original application does, except by using a
> combination of Spring Boot and Camel with XML route configuration.
>
> I downloaded the original application code (both the Camel consumer
> and the HTTP server) and got those to run and execute properly very easily.
>
> 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.
>
> I made the changes that seemed to make sense, but cannot get the
> application to run. I get the following exception:
>
>      Exception in thread "main" java.lang.IllegalAccessError: tried to
> access method
> org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryN
> ames(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.<init>(SpringApplication.java:268)
>            at
> org.springframework.boot.SpringApplication.<init>(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)
>
> 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.
>
> ApplicationMain.java:
>
>      @SpringBootApplication
>      @ImportResource("classpath:camel-context.xml")
>      public class ApplicationMain {
>        public static void main(String[] args) {
>            SpringApplication.run(ApplicationMain.class, args);
>        }
>      }
>
> Configurer.java:
>
>      @Configuration
>      @ComponentScan("org.test")
>      public class Configurer {
>        @Bean
>        public MyProcessor myProcessor() {
>            return new MyProcessor();
>        }
>      }
>
> application.yml:
>
>      ---
>      camel:
>        springboot:
>            name: CamelConsumer
>            main-run-controller: true
>
> camel-context.xml:
>
>      <?xml version="1.0" encoding="UTF-8"?>
>      <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">
>
>        <import resource="classpath:routes/routes.xml" />
>
>        <camelContext id="camel-context" xmlns="
> http://camel.apache.org/schema/spring">
>            <routeContextRef ref="routes" />
>        </camelContext>
>      </beans>
>
> routes/routes.xml:
>
> **Note**: 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.
>
>      <?xml version="1.0" encoding="UTF-8"?>
>      <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">
>
>        <bean id="myProcessor" class="org.test.processor.MyProcessor"
> />
>
>        <routeContext id="routes" xmlns="
> http://camel.apache.org/schema/spring">
>            <route id="httpTest">
>              <from uri="file:C:/inboxREST?noop=true" />
>              <setHeader headerName="HTTP_METHOD">
>                 <simple>GET</simple>
>              </setHeader>
>              <to uri="http://localhost:8080/employee?id=5" />
>              <process ref="myProcessor" />
>            </route>
>        </routeContext>
>      </beans>
>
> MyProcessor.java:
>
>      public class MyProcessor implements Processor {
>        public MyProcessor() {
>        }
>        public void process(Exchange exchange) throws Exception {
>           System.out.println(exchange.getIn().getBody(String.class));
>        }
>      }
>
> pom.xml:
>
> **Note**: 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?
>
>      <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">
>        <modelVersion>4.0.0</modelVersion>
>
>        <groupId>com.javainuse</groupId>
>        <artifactId>apache-camel-consume</artifactId>
>        <version>0.0.1-SNAPSHOT</version>
>
>        <parent>
>            <groupId>org.springframework.boot</groupId>
>            <artifactId>spring-boot-starter-parent</artifactId>
>            <version>2.1.6.RELEASE</version>
>            <relativePath />
>        </parent>
>
>        <properties>
>            <java.version>1.8</java.version>
>
>
>  <apache-camel-springboot.version>3.1.0</apache-camel-springboot.version>
>            <apache-camel.version>3.1.0</apache-camel.version>
>        </properties>
>
>        <dependencies>
>
>            <!-- Camel BOM -->
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-spring-boot-dependencies</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>              <type>pom</type>
>              <scope>import</scope>
>            </dependency>
>
>            <!-- Camel Starter -->
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-spring-boot-starter</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>            </dependency>
>
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-spring-boot</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>            </dependency>
>
>            <!-- Camel HTTP -->
>            <dependency>
>              <groupId>org.apache.camel</groupId>
>              <artifactId>camel-http</artifactId>
>              <version>${apache-camel.version}</version>
>            </dependency>
>
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-http-starter</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>            </dependency>
>
>            <!-- Camel Jackson -->
>            <dependency>
>              <groupId>org.apache.camel.springboot</groupId>
>              <artifactId>camel-jackson-starter</artifactId>
>              <version>${apache-camel-springboot.version}</version>
>            </dependency>
>
>            <!-- Spring Boot -->
>
>            <dependency>
>              <groupId>org.springframework.boot</groupId>
>              <artifactId>spring-boot-starter</artifactId>
>              <exclusions>
>                 <exclusion>
>                   <groupId>org.springframework.boot</groupId>
>                   <artifactId>spring-boot-starter-logging</artifactId>
>                 </exclusion>
>              </exclusions>
>            </dependency>
>
>            <dependency>
>              <groupId>org.springframework.boot</groupId>
>              <artifactId>spring-boot-starter-web</artifactId>
>              <exclusions>
>                 <exclusion>
>                   <groupId>org.springframework.boot</groupId>
>                   <artifactId>spring-boot-starter-tomcat</artifactId>
>                 </exclusion>
>                 <exclusion>
>                   <groupId>org.springframework.boot</groupId>
>                   <artifactId>spring-boot-starter-logging</artifactId>
>                 </exclusion>
>              </exclusions>
>            </dependency>
>
>        </dependencies>
>
>        <build>
>            <plugins>
>              <plugin>
>                 <groupId>org.apache.maven.plugins</groupId>
>                 <artifactId>maven-compiler-plugin</artifactId>
>                 <version>3.1</version>
>              </plugin>
>
>              <plugin>
>                 <groupId>org.apache.felix</groupId>
>                 <artifactId>maven-bundle-plugin</artifactId>
>                 <extensions>true</extensions>
>                 <version>2.4.0</version>
>              </plugin>
>            </plugins>
>        </build>
>
>      </project>
>
> Can anyone tell me what I'm doing wrong?
>
> Thanks,
> Joe Gagnon
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Spring Boot Camel application

Alex Dettinger
Ok, good to know that it's solved :)

On Thu, Apr 2, 2020 at 1:25 PM Gagnon, Joseph - 0553 - MITLL <
[hidden email]> wrote:

> Alex,
>
> I think that's what the problem was. I eventually, cleared out my local
> maven repo (.m2/repository) and then also needed to remove jars from the
> eclipse project settings.
>
> Once this was done and the project rebuilt, the problem was finally
> resolved.
>
> My guess is that the original project that was basing my code on, which I
> had downloaded, built and run, pulled in the older dependencies, resulting
> in the conflict.
>
> Thanks,
> Joe
>
> -----Original Message-----
> From: Alex Dettinger <[hidden email]>
> Sent: Thursday, April 2, 2020 3:51 AM
> To: [hidden email]
> Subject: Re: Problem with Spring Boot Camel application
>
> Hi Joe,
>
>   Maybe versions alignment, If I'm right mvn dependency:tree would show
> non aligned version while you should have something like camel 3.1.0 /
> spring 5.2.3.RELEASE / spring boot 2.2.4.RELEASE.
>   Checking other examples may help in this regard, they should be
> available here
> https://github.com/apache/camel-spring-boot/tree/camel-spring-boot-3.1.x/examples
> .
>
> Cheers,
> Alex
>
>
>
>
> On Wed, Apr 1, 2020 at 5:21 PM Gagnon, Joseph - 0553 - MITLL <
> [hidden email]> wrote:
>
> > Hello,
> >
> > I am still very new to using Apache Camel and am trying to adapt an
> > example provided by someone (
> > https://www.javainuse.com/camel/camel-consume-rest) to essentially do
> > the same thing the original application does, except by using a
> > combination of Spring Boot and Camel with XML route configuration.
> >
> > I downloaded the original application code (both the Camel consumer
> > and the HTTP server) and got those to run and execute properly very
> easily.
> >
> > 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.
> >
> > I made the changes that seemed to make sense, but cannot get the
> > application to run. I get the following exception:
> >
> >      Exception in thread "main" java.lang.IllegalAccessError: tried to
> > access method
> > org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryN
> > ames(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.<init>(SpringApplication.java:268)
> >            at
> >
> org.springframework.boot.SpringApplication.<init>(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)
> >
> > 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.
> >
> > ApplicationMain.java:
> >
> >      @SpringBootApplication
> >      @ImportResource("classpath:camel-context.xml")
> >      public class ApplicationMain {
> >        public static void main(String[] args) {
> >            SpringApplication.run(ApplicationMain.class, args);
> >        }
> >      }
> >
> > Configurer.java:
> >
> >      @Configuration
> >      @ComponentScan("org.test")
> >      public class Configurer {
> >        @Bean
> >        public MyProcessor myProcessor() {
> >            return new MyProcessor();
> >        }
> >      }
> >
> > application.yml:
> >
> >      ---
> >      camel:
> >        springboot:
> >            name: CamelConsumer
> >            main-run-controller: true
> >
> > camel-context.xml:
> >
> >      <?xml version="1.0" encoding="UTF-8"?>
> >      <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">
> >
> >        <import resource="classpath:routes/routes.xml" />
> >
> >        <camelContext id="camel-context" xmlns="
> > http://camel.apache.org/schema/spring">
> >            <routeContextRef ref="routes" />
> >        </camelContext>
> >      </beans>
> >
> > routes/routes.xml:
> >
> > **Note**: 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.
> >
> >      <?xml version="1.0" encoding="UTF-8"?>
> >      <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">
> >
> >        <bean id="myProcessor" class="org.test.processor.MyProcessor"
> > />
> >
> >        <routeContext id="routes" xmlns="
> > http://camel.apache.org/schema/spring">
> >            <route id="httpTest">
> >              <from uri="file:C:/inboxREST?noop=true" />
> >              <setHeader headerName="HTTP_METHOD">
> >                 <simple>GET</simple>
> >              </setHeader>
> >              <to uri="http://localhost:8080/employee?id=5" />
> >              <process ref="myProcessor" />
> >            </route>
> >        </routeContext>
> >      </beans>
> >
> > MyProcessor.java:
> >
> >      public class MyProcessor implements Processor {
> >        public MyProcessor() {
> >        }
> >        public void process(Exchange exchange) throws Exception {
> >           System.out.println(exchange.getIn().getBody(String.class));
> >        }
> >      }
> >
> > pom.xml:
> >
> > **Note**: 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?
> >
> >      <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">
> >        <modelVersion>4.0.0</modelVersion>
> >
> >        <groupId>com.javainuse</groupId>
> >        <artifactId>apache-camel-consume</artifactId>
> >        <version>0.0.1-SNAPSHOT</version>
> >
> >        <parent>
> >            <groupId>org.springframework.boot</groupId>
> >            <artifactId>spring-boot-starter-parent</artifactId>
> >            <version>2.1.6.RELEASE</version>
> >            <relativePath />
> >        </parent>
> >
> >        <properties>
> >            <java.version>1.8</java.version>
> >
> >
> >  <apache-camel-springboot.version>3.1.0</apache-camel-springboot.version>
> >            <apache-camel.version>3.1.0</apache-camel.version>
> >        </properties>
> >
> >        <dependencies>
> >
> >            <!-- Camel BOM -->
> >            <dependency>
> >              <groupId>org.apache.camel.springboot</groupId>
> >              <artifactId>camel-spring-boot-dependencies</artifactId>
> >              <version>${apache-camel-springboot.version}</version>
> >              <type>pom</type>
> >              <scope>import</scope>
> >            </dependency>
> >
> >            <!-- Camel Starter -->
> >            <dependency>
> >              <groupId>org.apache.camel.springboot</groupId>
> >              <artifactId>camel-spring-boot-starter</artifactId>
> >              <version>${apache-camel-springboot.version}</version>
> >            </dependency>
> >
> >            <dependency>
> >              <groupId>org.apache.camel.springboot</groupId>
> >              <artifactId>camel-spring-boot</artifactId>
> >              <version>${apache-camel-springboot.version}</version>
> >            </dependency>
> >
> >            <!-- Camel HTTP -->
> >            <dependency>
> >              <groupId>org.apache.camel</groupId>
> >              <artifactId>camel-http</artifactId>
> >              <version>${apache-camel.version}</version>
> >            </dependency>
> >
> >            <dependency>
> >              <groupId>org.apache.camel.springboot</groupId>
> >              <artifactId>camel-http-starter</artifactId>
> >              <version>${apache-camel-springboot.version}</version>
> >            </dependency>
> >
> >            <!-- Camel Jackson -->
> >            <dependency>
> >              <groupId>org.apache.camel.springboot</groupId>
> >              <artifactId>camel-jackson-starter</artifactId>
> >              <version>${apache-camel-springboot.version}</version>
> >            </dependency>
> >
> >            <!-- Spring Boot -->
> >
> >            <dependency>
> >              <groupId>org.springframework.boot</groupId>
> >              <artifactId>spring-boot-starter</artifactId>
> >              <exclusions>
> >                 <exclusion>
> >                   <groupId>org.springframework.boot</groupId>
> >                   <artifactId>spring-boot-starter-logging</artifactId>
> >                 </exclusion>
> >              </exclusions>
> >            </dependency>
> >
> >            <dependency>
> >              <groupId>org.springframework.boot</groupId>
> >              <artifactId>spring-boot-starter-web</artifactId>
> >              <exclusions>
> >                 <exclusion>
> >                   <groupId>org.springframework.boot</groupId>
> >                   <artifactId>spring-boot-starter-tomcat</artifactId>
> >                 </exclusion>
> >                 <exclusion>
> >                   <groupId>org.springframework.boot</groupId>
> >                   <artifactId>spring-boot-starter-logging</artifactId>
> >                 </exclusion>
> >              </exclusions>
> >            </dependency>
> >
> >        </dependencies>
> >
> >        <build>
> >            <plugins>
> >              <plugin>
> >                 <groupId>org.apache.maven.plugins</groupId>
> >                 <artifactId>maven-compiler-plugin</artifactId>
> >                 <version>3.1</version>
> >              </plugin>
> >
> >              <plugin>
> >                 <groupId>org.apache.felix</groupId>
> >                 <artifactId>maven-bundle-plugin</artifactId>
> >                 <extensions>true</extensions>
> >                 <version>2.4.0</version>
> >              </plugin>
> >            </plugins>
> >        </build>
> >
> >      </project>
> >
> > Can anyone tell me what I'm doing wrong?
> >
> > Thanks,
> > Joe Gagnon
> >
> >
>