You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jesper Duelund Isaksen <je...@systematic.com.INVALID> on 2021/01/28 10:44:16 UTC
Spring Boot, Apache Camel and Undertow
Hello,
In my team we are currently attempting to develop a Spring Boot 2.4.2 gateway application which uses Apache Camel 3.7.1 to expose generic http routes using the Undertow component and routes using the REST DSL.
I assume that we are not correctly configuring the application since given the pom.xml below and having manually configured the RestComponent to use undertow as consumer, it seems two embedded Undertow instances are started. The logs below show this.
When the test run they fail since they expect the endpoints to be found on port 9080.
Does anyone know what we are doing wrong or misconfiguring in this case?
2021-01-28 11:33:10.741 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
2021-01-28 11:33:10.854 INFO 13246 --- [ main] o.s.b.w.e.undertow.UndertowWebServer : Undertow started on port(s) 9080 (http)
...
2021-01-28 11:33:11.194 INFO 13246 --- [ main] o.a.c.c.undertow.DefaultUndertowHost : Starting Undertow server on http://0.0.0.0:0
2021-01-28 11:33:11.194 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint1 started and consuming from: http://0.0.0.0:0/test/endpoint1
2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint2 started and consuming from: http://0.0.0.0:0/test/endpoint2
...
Tests running ...
...
2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] o.a.c.c.undertow.DefaultUndertowHost : Stopping Undertow server on http://0.0.0.0:0
2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] io.undertow : stopping server: Undertow - 2.2.3.Final
...
2021-01-28 11:33:11.705 INFO 13246 --- [extShutdownHook] io.undertow : stopping server: Undertow - 2.2.3.Final
Maven pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.test.gateway-lib</groupId>
<artifactId>gateway-lib</artifactId>
<name>gateway-lib</name>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
<version.camel>3.7.1</version.camel>
<version.spring-boot>2.4.2</version.spring-boot>
</properties>
<dependencyManagement>
<dependencies>
<!-- Camel BOM -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-dependencies</artifactId>
<version>${version.camel}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Spring Boot BOM -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring-boot}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Spring dependencies -->
<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>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Camel dependencies -->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-servlet-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-undertow-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-metrics-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-http-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-hystrix-starter</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Kind regards
Jesper Isaksen
RE: Spring Boot, Apache Camel and Undertow
Posted by Jesper Duelund Isaksen <je...@systematic.com.INVALID>.
Hi again
I've created the following bug report incl. a reproducer linked in the bug report regarding the issue:
CAMEL-16109 - https://issues.apache.org/jira/browse/CAMEL-16109
Feel free to contact me if you need more information.
Kind regards
Jesper Duelund Isaksen
-----Original Message-----
From: Claus Ibsen <cl...@gmail.com>
Sent: 28. januar 2021 14:40
To: users@camel.apache.org
Subject: Re: Spring Boot, Apache Camel and Undertow
CAUTION - External Mail
Hi
Ah can you create a JIRA about the camel-hystrix-starter issue.
Yeah using plain camel-hystrix is fine as it will then skip the auto configuration, but you can use hystrix anyway.
On Thu, Jan 28, 2021 at 2:19 PM Jesper Duelund Isaksen <je...@systematic.com.invalid> wrote:
>
> Thanks for the quick reply Claus.
>
> That did indeed help. It seems we must then change any existing routes declared as 'from("servlet:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A9080%2Ftest%2Fendpoint3&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423648116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Kzq610sRtx%2F2CgyBqs6VixSc%2FMFbM%2BK%2BnlhoqmRyWfI%3D&reserved=0")' instead of 'from("undertow:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A9080%2Ftest%2Fendpoint3&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423648116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Kzq610sRtx%2F2CgyBqs6VixSc%2FMFbM%2BK%2BnlhoqmRyWfI%3D&reserved=0")'.
>
> The camel-hystrix-starter does need to be removed now though. It results in the following error:
>
> BeanDefinitionOverrideException: Invalid bean definition with name 'servletRegistrationBean' defined in class path resource [org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.apache.camel.component.servlet.springboot.ServletMappingAutoConfiguration; factoryMethodName=servletRegistrationBean; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.class]] for bean 'servletRegistrationBean': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.apache.camel.component.hystrix.springboot.HystrixMappingAutoConfiguration; factoryMethodName=servletRegistrationBean; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/apache/camel/component/hystrix/springboot/HystrixMappingAutoConfiguration.class]] bound.
>
> It works if I change back to the "regular" camel-hystrix dependency. Would that be correct?
>
> Kind regards
> Jesper Duelund Isaksen
>
> -----Original Message-----
> From: Claus Ibsen <cl...@gmail.com>
> Sent: 28. januar 2021 13:30
> To: users@camel.apache.org
> Subject: Re: Spring Boot, Apache Camel and Undertow
>
> Hi
>
> You should use camel-servlet-starter to tie to the undertow from spring boot itself.
>
> On Thu, Jan 28, 2021 at 11:53 AM Jesper Duelund Isaksen <je...@systematic.com.invalid> wrote:
> >
> > Hello,
> >
> > In my team we are currently attempting to develop a Spring Boot 2.4.2 gateway application which uses Apache Camel 3.7.1 to expose generic http routes using the Undertow component and routes using the REST DSL.
> >
> > I assume that we are not correctly configuring the application since given the pom.xml below and having manually configured the RestComponent to use undertow as consumer, it seems two embedded Undertow instances are started. The logs below show this.
> > When the test run they fail since they expect the endpoints to be found on port 9080.
> >
> > Does anyone know what we are doing wrong or misconfiguring in this case?
> >
> > 2021-01-28 11:33:10.741 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
> > 2021-01-28 11:33:10.854 INFO 13246 --- [ main] o.s.b.w.e.undertow.UndertowWebServer : Undertow started on port(s) 9080 (http)
> > ...
> > 2021-01-28 11:33:11.194 INFO 13246 --- [ main] o.a.c.c.undertow.DefaultUndertowHost : Starting Undertow server on https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423648116%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=VgaaqoYdhfemISPcbBdiWsM5AwZKZrVgaEP%2B%2FJol2b8%3D&reserved=0
> > 2021-01-28 11:33:11.194 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
> > 2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint1 started and consuming from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2Ftest%2Fendpoint1&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423658083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=VVyYaaVmH8N%2F%2FSutNMibXPz34KmgI87Bc8g5QXkkP04%3D&reserved=0
> > 2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint2 started and consuming from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2Ftest%2Fendpoint2&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423658083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jSkXu%2B064CYqarEEDw8S6rEI%2BrAHUv15Poc5%2B7MMBUI%3D&reserved=0
> > ...
> > Tests running ...
> > ...
> > 2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] o.a.c.c.undertow.DefaultUndertowHost : Stopping Undertow server on https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423658083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rPAw1gSx2SoDEn03TbooHMHNq07wmlnWNP%2BatiPT7JA%3D&reserved=0
> > 2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] io.undertow : stopping server: Undertow - 2.2.3.Final
> > ...
> > 2021-01-28 11:33:11.705 INFO 13246 --- [extShutdownHook] io.undertow : stopping server: Undertow - 2.2.3.Final
> >
> >
> >
> > Maven pom.xml:
> >
> > <project xmlns="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2FPOM%2F4.0.0&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423658083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=zxGq2l%2BwoCK8Ie9%2B%2BgCwUtfix9CUAQ2MLKIp5rQ7VnQ%3D&reserved=0" xmlns:xsi="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423658083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ZQzKlXFiaK494xvOMoQAHt9NX1h%2Fg6esthCFVk1BBaA%3D&reserved=0" xsi:schemaLocation="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2FPOM%2F4.0.0&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423658083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=zxGq2l%2BwoCK8Ie9%2B%2BgCwUtfix9CUAQ2MLKIp5rQ7VnQ%3D&reserved=0 https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2Fmaven-v4_0_0.xsd&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423658083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dA9NXXncqvo7eCvcO1%2FJEprtjCS4nrh54nhD3y4FXjs%3D&reserved=0">
> > <modelVersion>4.0.0</modelVersion>
> >
> > <groupId>org.test.gateway-lib</groupId>
> > <artifactId>gateway-lib</artifactId>
> > <name>gateway-lib</name>
> > <version>1.0.0-SNAPSHOT</version>
> > <packaging>jar</packaging>
> >
> > <properties>
> > <java.version>11</java.version>
> > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> > <project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
> > <version.camel>3.7.1</version.camel>
> > <version.spring-boot>2.4.2</version.spring-boot>
> > </properties>
> >
> > <dependencyManagement>
> > <dependencies>
> > <!-- Camel BOM -->
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-spring-boot-dependencies</artifactId>
> > <version>${version.camel}</version>
> > <type>pom</type>
> > <scope>import</scope>
> > </dependency>
> > <!-- Spring Boot BOM -->
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-dependencies</artifactId>
> > <version>${version.spring-boot}</version>
> > <type>pom</type>
> > <scope>import</scope>
> > </dependency>
> > </dependencies>
> > </dependencyManagement>
> >
> > <dependencies>
> > <!-- Spring dependencies -->
> > <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>
> > </exclusions>
> > </dependency>
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-undertow</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-cache</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-actuator</artifactId>
> > </dependency>
> >
> > <!-- Camel dependencies -->
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-spring-boot-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-servlet-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-undertow-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-metrics-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-http-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-hystrix-starter</artifactId>
> > </dependency>
> >
> > <!-- test -->
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-test</artifactId>
> > <scope>test</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel</groupId>
> > <artifactId>camel-test-spring-junit5</artifactId>
> > <scope>test</scope>
> > </dependency>
> > </dependencies>
> >
> > <build>
> > <plugins>
> > <plugin>
> > <groupId>org.apache.maven.plugins</groupId>
> > <artifactId>maven-compiler-plugin</artifactId>
> > <version>3.8.1</version>
> > <configuration>
> > <source>11</source>
> > <target>11</target>
> > </configuration>
> > </plugin>
> > </plugins>
> > </build>
> > </project>
> >
> >
> > Kind regards
> > Jesper Isaksen
>
>
>
> --
> Claus Ibsen
> -----------------
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdavsc
> laus.com%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com
> %7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408
> %7C0%7C0%7C637474380423658083%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=vC
> bucJN9UmIKzWdlur%2FEpatapL9fZxAd7gm%2FzdfUhVw%3D&reserved=0
> @davsclaus Camel in Action 2:
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
> manning.com%2Fibsen2&data=04%7C01%7Cjesper.duelund.isaksen%40syste
> matic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0c
> cbd7f0408%7C0%7C0%7C637474380423668031%7CUnknown%7CTWFpbGZsb3d8eyJWIjo
> iMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&
> ;sdata=VQeEg9h2ITPaBW9JiRq23NKq5HxSrpJjUMj1XPP%2FLbg%3D&reserved=0
--
Claus Ibsen
-----------------
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdavsclaus.com%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423668031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2F%2FRa4peywPp6mNudZbmHja5DgwNt1s0JOlCRCWQXtp8%3D&reserved=0 @davsclaus Camel in Action 2: https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.manning.com%2Fibsen2&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C4ebd5b6bc8ff4f2ae98608d8c3924e1c%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474380423668031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=VQeEg9h2ITPaBW9JiRq23NKq5HxSrpJjUMj1XPP%2FLbg%3D&reserved=0
Re: Spring Boot, Apache Camel and Undertow
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Ah can you create a JIRA about the camel-hystrix-starter issue.
Yeah using plain camel-hystrix is fine as it will then skip the auto
configuration, but you can use hystrix anyway.
On Thu, Jan 28, 2021 at 2:19 PM Jesper Duelund Isaksen
<je...@systematic.com.invalid> wrote:
>
> Thanks for the quick reply Claus.
>
> That did indeed help. It seems we must then change any existing routes declared as 'from("servlet:http://0.0.0.0:9080/test/endpoint3")' instead of 'from("undertow:http://0.0.0.0:9080/test/endpoint3")'.
>
> The camel-hystrix-starter does need to be removed now though. It results in the following error:
>
> BeanDefinitionOverrideException: Invalid bean definition with name 'servletRegistrationBean' defined in class path resource [org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.apache.camel.component.servlet.springboot.ServletMappingAutoConfiguration; factoryMethodName=servletRegistrationBean; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.class]] for bean 'servletRegistrationBean': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.apache.camel.component.hystrix.springboot.HystrixMappingAutoConfiguration; factoryMethodName=servletRegistrationBean; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/apache/camel/component/hystrix/springboot/HystrixMappingAutoConfiguration.class]] bound.
>
> It works if I change back to the "regular" camel-hystrix dependency. Would that be correct?
>
> Kind regards
> Jesper Duelund Isaksen
>
> -----Original Message-----
> From: Claus Ibsen <cl...@gmail.com>
> Sent: 28. januar 2021 13:30
> To: users@camel.apache.org
> Subject: Re: Spring Boot, Apache Camel and Undertow
>
> Hi
>
> You should use camel-servlet-starter to tie to the undertow from spring boot itself.
>
> On Thu, Jan 28, 2021 at 11:53 AM Jesper Duelund Isaksen <je...@systematic.com.invalid> wrote:
> >
> > Hello,
> >
> > In my team we are currently attempting to develop a Spring Boot 2.4.2 gateway application which uses Apache Camel 3.7.1 to expose generic http routes using the Undertow component and routes using the REST DSL.
> >
> > I assume that we are not correctly configuring the application since given the pom.xml below and having manually configured the RestComponent to use undertow as consumer, it seems two embedded Undertow instances are started. The logs below show this.
> > When the test run they fail since they expect the endpoints to be found on port 9080.
> >
> > Does anyone know what we are doing wrong or misconfiguring in this case?
> >
> > 2021-01-28 11:33:10.741 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
> > 2021-01-28 11:33:10.854 INFO 13246 --- [ main] o.s.b.w.e.undertow.UndertowWebServer : Undertow started on port(s) 9080 (http)
> > ...
> > 2021-01-28 11:33:11.194 INFO 13246 --- [ main] o.a.c.c.undertow.DefaultUndertowHost : Starting Undertow server on https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426843386%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=58N4TgoVBiZ3hGgEox7ay%2BaK8J6CueM51d84VSgffZ0%3D&reserved=0
> > 2021-01-28 11:33:11.194 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
> > 2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint1 started and consuming from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2Ftest%2Fendpoint1&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426843386%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dMQ4vDeunBrvNA%2FVCORVrtg2%2BrwB6dQHT1dVftTeCUs%3D&reserved=0
> > 2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint2 started and consuming from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2Ftest%2Fendpoint2&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426843386%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=IdD9tEPaj%2FuQIk3%2F%2F7MR%2BpiC8hZoabugyfEy7r%2B6Bw8%3D&reserved=0
> > ...
> > Tests running ...
> > ...
> > 2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] o.a.c.c.undertow.DefaultUndertowHost : Stopping Undertow server on https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=BdkXh4x2no%2FsGEQpmHGOZS9ZgrYKNna1GvNT5fbS7gg%3D&reserved=0
> > 2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] io.undertow : stopping server: Undertow - 2.2.3.Final
> > ...
> > 2021-01-28 11:33:11.705 INFO 13246 --- [extShutdownHook] io.undertow : stopping server: Undertow - 2.2.3.Final
> >
> >
> >
> > Maven pom.xml:
> >
> > <project xmlns="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2FPOM%2F4.0.0&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2FJIorhIHfTZjv4P%2BMC7xyoIJ3jTq9xL4CKTAN4DW8HQ%3D&reserved=0" xmlns:xsi="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=zTYin0PxiHitGTTLJ4YYZgEZgKB5hmFh2owMxm0A0to%3D&reserved=0" xsi:schemaLocation="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2FPOM%2F4.0.0&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2FJIorhIHfTZjv4P%2BMC7xyoIJ3jTq9xL4CKTAN4DW8HQ%3D&reserved=0 https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2Fmaven-v4_0_0.xsd&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3VeNGq7YAoedG7ggnu7lsMMANG51D8rEDPPdNqQvv8o%3D&reserved=0">
> > <modelVersion>4.0.0</modelVersion>
> >
> > <groupId>org.test.gateway-lib</groupId>
> > <artifactId>gateway-lib</artifactId>
> > <name>gateway-lib</name>
> > <version>1.0.0-SNAPSHOT</version>
> > <packaging>jar</packaging>
> >
> > <properties>
> > <java.version>11</java.version>
> > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> > <project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
> > <version.camel>3.7.1</version.camel>
> > <version.spring-boot>2.4.2</version.spring-boot>
> > </properties>
> >
> > <dependencyManagement>
> > <dependencies>
> > <!-- Camel BOM -->
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-spring-boot-dependencies</artifactId>
> > <version>${version.camel}</version>
> > <type>pom</type>
> > <scope>import</scope>
> > </dependency>
> > <!-- Spring Boot BOM -->
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-dependencies</artifactId>
> > <version>${version.spring-boot}</version>
> > <type>pom</type>
> > <scope>import</scope>
> > </dependency>
> > </dependencies>
> > </dependencyManagement>
> >
> > <dependencies>
> > <!-- Spring dependencies -->
> > <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>
> > </exclusions>
> > </dependency>
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-undertow</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-cache</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-actuator</artifactId>
> > </dependency>
> >
> > <!-- Camel dependencies -->
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-spring-boot-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-servlet-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-undertow-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-metrics-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-http-starter</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel.springboot</groupId>
> > <artifactId>camel-hystrix-starter</artifactId>
> > </dependency>
> >
> > <!-- test -->
> > <dependency>
> > <groupId>org.springframework.boot</groupId>
> > <artifactId>spring-boot-starter-test</artifactId>
> > <scope>test</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.camel</groupId>
> > <artifactId>camel-test-spring-junit5</artifactId>
> > <scope>test</scope>
> > </dependency>
> > </dependencies>
> >
> > <build>
> > <plugins>
> > <plugin>
> > <groupId>org.apache.maven.plugins</groupId>
> > <artifactId>maven-compiler-plugin</artifactId>
> > <version>3.8.1</version>
> > <configuration>
> > <source>11</source>
> > <target>11</target>
> > </configuration>
> > </plugin>
> > </plugins>
> > </build>
> > </project>
> >
> >
> > Kind regards
> > Jesper Isaksen
>
>
>
> --
> Claus Ibsen
> -----------------
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdavsclaus.com%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=p3u5s%2BkkKEfbaQxTRVyVSP00eIGzS%2Bia01DoFtK7ErM%3D&reserved=0 @davsclaus Camel in Action 2: https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.manning.com%2Fibsen2&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=8rFJ7FrIidLgtUKJaNFoXWQ3KkUleatX5k8QCF9PLe4%3D&reserved=0
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
RE: Spring Boot, Apache Camel and Undertow
Posted by Jesper Duelund Isaksen <je...@systematic.com.INVALID>.
Thanks for the quick reply Claus.
That did indeed help. It seems we must then change any existing routes declared as 'from("servlet:http://0.0.0.0:9080/test/endpoint3")' instead of 'from("undertow:http://0.0.0.0:9080/test/endpoint3")'.
The camel-hystrix-starter does need to be removed now though. It results in the following error:
BeanDefinitionOverrideException: Invalid bean definition with name 'servletRegistrationBean' defined in class path resource [org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.apache.camel.component.servlet.springboot.ServletMappingAutoConfiguration; factoryMethodName=servletRegistrationBean; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/apache/camel/component/servlet/springboot/ServletMappingAutoConfiguration.class]] for bean 'servletRegistrationBean': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.apache.camel.component.hystrix.springboot.HystrixMappingAutoConfiguration; factoryMethodName=servletRegistrationBean; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/apache/camel/component/hystrix/springboot/HystrixMappingAutoConfiguration.class]] bound.
It works if I change back to the "regular" camel-hystrix dependency. Would that be correct?
Kind regards
Jesper Duelund Isaksen
-----Original Message-----
From: Claus Ibsen <cl...@gmail.com>
Sent: 28. januar 2021 13:30
To: users@camel.apache.org
Subject: Re: Spring Boot, Apache Camel and Undertow
Hi
You should use camel-servlet-starter to tie to the undertow from spring boot itself.
On Thu, Jan 28, 2021 at 11:53 AM Jesper Duelund Isaksen <je...@systematic.com.invalid> wrote:
>
> Hello,
>
> In my team we are currently attempting to develop a Spring Boot 2.4.2 gateway application which uses Apache Camel 3.7.1 to expose generic http routes using the Undertow component and routes using the REST DSL.
>
> I assume that we are not correctly configuring the application since given the pom.xml below and having manually configured the RestComponent to use undertow as consumer, it seems two embedded Undertow instances are started. The logs below show this.
> When the test run they fail since they expect the endpoints to be found on port 9080.
>
> Does anyone know what we are doing wrong or misconfiguring in this case?
>
> 2021-01-28 11:33:10.741 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
> 2021-01-28 11:33:10.854 INFO 13246 --- [ main] o.s.b.w.e.undertow.UndertowWebServer : Undertow started on port(s) 9080 (http)
> ...
> 2021-01-28 11:33:11.194 INFO 13246 --- [ main] o.a.c.c.undertow.DefaultUndertowHost : Starting Undertow server on https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426843386%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=58N4TgoVBiZ3hGgEox7ay%2BaK8J6CueM51d84VSgffZ0%3D&reserved=0
> 2021-01-28 11:33:11.194 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
> 2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint1 started and consuming from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2Ftest%2Fendpoint1&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426843386%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dMQ4vDeunBrvNA%2FVCORVrtg2%2BrwB6dQHT1dVftTeCUs%3D&reserved=0
> 2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint2 started and consuming from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2Ftest%2Fendpoint2&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426843386%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=IdD9tEPaj%2FuQIk3%2F%2F7MR%2BpiC8hZoabugyfEy7r%2B6Bw8%3D&reserved=0
> ...
> Tests running ...
> ...
> 2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] o.a.c.c.undertow.DefaultUndertowHost : Stopping Undertow server on https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2F0.0.0.0%3A0%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=BdkXh4x2no%2FsGEQpmHGOZS9ZgrYKNna1GvNT5fbS7gg%3D&reserved=0
> 2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] io.undertow : stopping server: Undertow - 2.2.3.Final
> ...
> 2021-01-28 11:33:11.705 INFO 13246 --- [extShutdownHook] io.undertow : stopping server: Undertow - 2.2.3.Final
>
>
>
> Maven pom.xml:
>
> <project xmlns="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2FPOM%2F4.0.0&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2FJIorhIHfTZjv4P%2BMC7xyoIJ3jTq9xL4CKTAN4DW8HQ%3D&reserved=0" xmlns:xsi="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=zTYin0PxiHitGTTLJ4YYZgEZgKB5hmFh2owMxm0A0to%3D&reserved=0" xsi:schemaLocation="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2FPOM%2F4.0.0&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2FJIorhIHfTZjv4P%2BMC7xyoIJ3jTq9xL4CKTAN4DW8HQ%3D&reserved=0 https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmaven.apache.org%2Fmaven-v4_0_0.xsd&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3VeNGq7YAoedG7ggnu7lsMMANG51D8rEDPPdNqQvv8o%3D&reserved=0">
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>org.test.gateway-lib</groupId>
> <artifactId>gateway-lib</artifactId>
> <name>gateway-lib</name>
> <version>1.0.0-SNAPSHOT</version>
> <packaging>jar</packaging>
>
> <properties>
> <java.version>11</java.version>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
> <version.camel>3.7.1</version.camel>
> <version.spring-boot>2.4.2</version.spring-boot>
> </properties>
>
> <dependencyManagement>
> <dependencies>
> <!-- Camel BOM -->
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-spring-boot-dependencies</artifactId>
> <version>${version.camel}</version>
> <type>pom</type>
> <scope>import</scope>
> </dependency>
> <!-- Spring Boot BOM -->
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-dependencies</artifactId>
> <version>${version.spring-boot}</version>
> <type>pom</type>
> <scope>import</scope>
> </dependency>
> </dependencies>
> </dependencyManagement>
>
> <dependencies>
> <!-- Spring dependencies -->
> <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>
> </exclusions>
> </dependency>
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-undertow</artifactId>
> </dependency>
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-cache</artifactId>
> </dependency>
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-actuator</artifactId>
> </dependency>
>
> <!-- Camel dependencies -->
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-spring-boot-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-servlet-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-undertow-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-metrics-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-http-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-hystrix-starter</artifactId>
> </dependency>
>
> <!-- test -->
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-test</artifactId>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-test-spring-junit5</artifactId>
> <scope>test</scope>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>3.8.1</version>
> <configuration>
> <source>11</source>
> <target>11</target>
> </configuration>
> </plugin>
> </plugins>
> </build>
> </project>
>
>
> Kind regards
> Jesper Isaksen
--
Claus Ibsen
-----------------
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdavsclaus.com%2F&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=p3u5s%2BkkKEfbaQxTRVyVSP00eIGzS%2Bia01DoFtK7ErM%3D&reserved=0 @davsclaus Camel in Action 2: https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.manning.com%2Fibsen2&data=04%7C01%7Cjesper.duelund.isaksen%40systematic.com%7C0de09fb507ea49ff327708d8c3888655%7C7f6211b17c5c42778403c0ccbd7f0408%7C0%7C0%7C637474338426853339%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=8rFJ7FrIidLgtUKJaNFoXWQ3KkUleatX5k8QCF9PLe4%3D&reserved=0
Re: Spring Boot, Apache Camel and Undertow
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You should use camel-servlet-starter to tie to the undertow from
spring boot itself.
On Thu, Jan 28, 2021 at 11:53 AM Jesper Duelund Isaksen
<je...@systematic.com.invalid> wrote:
>
> Hello,
>
> In my team we are currently attempting to develop a Spring Boot 2.4.2 gateway application which uses Apache Camel 3.7.1 to expose generic http routes using the Undertow component and routes using the REST DSL.
>
> I assume that we are not correctly configuring the application since given the pom.xml below and having manually configured the RestComponent to use undertow as consumer, it seems two embedded Undertow instances are started. The logs below show this.
> When the test run they fail since they expect the endpoints to be found on port 9080.
>
> Does anyone know what we are doing wrong or misconfiguring in this case?
>
> 2021-01-28 11:33:10.741 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
> 2021-01-28 11:33:10.854 INFO 13246 --- [ main] o.s.b.w.e.undertow.UndertowWebServer : Undertow started on port(s) 9080 (http)
> ...
> 2021-01-28 11:33:11.194 INFO 13246 --- [ main] o.a.c.c.undertow.DefaultUndertowHost : Starting Undertow server on http://0.0.0.0:0
> 2021-01-28 11:33:11.194 INFO 13246 --- [ main] io.undertow : starting server: Undertow - 2.2.3.Final
> 2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint1 started and consuming from: http://0.0.0.0:0/test/endpoint1
> 2021-01-28 11:33:11.198 INFO 13246 --- [ main] o.a.c.i.e.InternalRouteStartupManager : Route: rest-endpoint2 started and consuming from: http://0.0.0.0:0/test/endpoint2
> ...
> Tests running ...
> ...
> 2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] o.a.c.c.undertow.DefaultUndertowHost : Stopping Undertow server on http://0.0.0.0:0
> 2021-01-28 11:33:11.691 INFO 13246 --- [ - ShutdownTask] io.undertow : stopping server: Undertow - 2.2.3.Final
> ...
> 2021-01-28 11:33:11.705 INFO 13246 --- [extShutdownHook] io.undertow : stopping server: Undertow - 2.2.3.Final
>
>
>
> Maven pom.xml:
>
> <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/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>org.test.gateway-lib</groupId>
> <artifactId>gateway-lib</artifactId>
> <name>gateway-lib</name>
> <version>1.0.0-SNAPSHOT</version>
> <packaging>jar</packaging>
>
> <properties>
> <java.version>11</java.version>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
> <version.camel>3.7.1</version.camel>
> <version.spring-boot>2.4.2</version.spring-boot>
> </properties>
>
> <dependencyManagement>
> <dependencies>
> <!-- Camel BOM -->
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-spring-boot-dependencies</artifactId>
> <version>${version.camel}</version>
> <type>pom</type>
> <scope>import</scope>
> </dependency>
> <!-- Spring Boot BOM -->
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-dependencies</artifactId>
> <version>${version.spring-boot}</version>
> <type>pom</type>
> <scope>import</scope>
> </dependency>
> </dependencies>
> </dependencyManagement>
>
> <dependencies>
> <!-- Spring dependencies -->
> <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>
> </exclusions>
> </dependency>
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-undertow</artifactId>
> </dependency>
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-cache</artifactId>
> </dependency>
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-actuator</artifactId>
> </dependency>
>
> <!-- Camel dependencies -->
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-spring-boot-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-servlet-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-undertow-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-metrics-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-http-starter</artifactId>
> </dependency>
> <dependency>
> <groupId>org.apache.camel.springboot</groupId>
> <artifactId>camel-hystrix-starter</artifactId>
> </dependency>
>
> <!-- test -->
> <dependency>
> <groupId>org.springframework.boot</groupId>
> <artifactId>spring-boot-starter-test</artifactId>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-test-spring-junit5</artifactId>
> <scope>test</scope>
> </dependency>
> </dependencies>
>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>3.8.1</version>
> <configuration>
> <source>11</source>
> <target>11</target>
> </configuration>
> </plugin>
> </plugins>
> </build>
> </project>
>
>
> Kind regards
> Jesper Isaksen
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2