1
votes

We're using the Camel REST DSL. We have it working (via the camel-spring-boot support) with the netty4-http component.

Relevant working code / config is as follows:

build.gradle:

dependencies {
    compile (group: 'org.apache.camel', name: 'camel-spring-boot', version: '2.16.1')
    compile (group: 'org.apache.camel', name: 'camel-netty4-http', version: '2.16.1')
    compile (group: 'org.apache.camel', name: 'camel-jackson', version: '2.16.1')
    compile (group: 'org.apache.camel', name: 'camel-swagger-java', version: '2.16.1')
    compile (group: 'org.apache.camel', name: 'camel-cxf', version: '2.16.1')
    compile (group: 'org.springframework.boot', name: 'spring-boot', version: '1.3.1.RELEASE')

our route:

@Component
public class ExampleRestDslRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {

        restConfiguration()
            .component("netty4-http")
            .bindingMode(RestBindingMode.json)
            .dataFormatProperty("prettyPrint", "true")
            .host("0.0.0.0")
            .contextPath(restApiBaseUrl)
            .port("10000")
            .apiContextPath("/api-doc")
            .apiProperty("api.description", restApiDesc)
            .apiProperty("api.title", restApiTitle)
            .apiProperty("api.version", restApiVersion) 
            .apiProperty("cors", "true");

        rest("/hello").description("Say hello.")
            .produces("application/json")
            .get().description("Get hello.").route().transform(constant("BOOOOOOOM!!!!!"));

    }

We'd like however to replace netty with the jetty component (Jetty being instrumented with Coda Hale metrics). From the docs ([1] & [2]) it appears we should make the following changes:

build.gradle:

compile (group: 'org.apache.camel', name: 'camel-jetty9', version: '2.16.1')

our route:

restConfiguration()
            .component("jetty")

However when we do, we see this stack trace at startup:

12:31:53.805 [main] ERROR o.springframework.boot.SpringApplication - Application startup failed
org.apache.camel.spring.boot.CamelSpringBootInitializationException: java.lang.IllegalArgumentException: Component jetty is not a RestApiConsumerFactory
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:87) ~[camel-spring-boot-2.16.1.jar:2.16.1]
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:37) ~[camel-spring-boot-2.16.1.jar:2.16.1]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:855) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:140) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:764) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.ringApplication.doRun(SpringApplication.java:357) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.apache.camel.spring.boot.FatJarRouter.main(FatJarRouter.java:26) [camel-spring-boot-2.16.1.jar:2.16.1]
Caused by: java.lang.IllegalArgumentException: Component jetty is not a RestApiConsumerFactory
    at org.apache.camel.component.rest.RestApiEndpoint.createConsumer(RestApiEndpoint.java:220) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:68) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:98) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.RouteService.warmUp(RouteService.java:158) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3453) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3383) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3160) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3016) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2812) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2808) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2831) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2808) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.support.Serport.start(ServiceSupport.java:61) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2777) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:85) ~[camel-spring-boot-2.16.1.jar:2.16.1]
    ... 13 common frames omitted

[1] https://camel.apache.org/rest-dsl.html [2] https://camel.apache.org/jetty.html

1
Try with 2.16.2 or the upcoming 2.16.3 as its fixed recently - Claus Ibsen
Thanks @ClausIbsen, I'll try right now. - Andrew Harmel-Law
That works. Thanks Claus. I'll add a answer to this. - Andrew Harmel-Law

1 Answers

1
votes

We needed to upgrade to version 2.16.2 of camel (thanks @clausibsen for this - see his comment above).

dependencies {
    compile (group: 'org.apache.camel', name: 'camel-spring-boot', version: '2.16.2')
    compile (group: 'org.apache.camel', name: 'camel-jetty9', version: '2.16.2')
    compile (group: 'org.apache.camel', name: 'camel-jackson', version: '2.16.2')
    compile (group: 'org.apache.camel', name: 'camel-swagger-java', version: '2.16.2')
    compile (group: 'org.apache.camel', name: 'camel-cxf', version: '2.16.2')
    compile (group: 'org.springframework.boot', name: 'spring-boot', version: '1.3.1.RELEASE')