Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-9868

Camel rest DSL does not work with SSL configuration and API doc on spring-boot

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • fuse-7.3
    • fuse-7.2
    • Camel
    • None
    • % %
    • Fuse 7.3 Sprint 39

      I try to configure REST endpoint using REST DSL with API doc (swagger). I want to use HTTPS protocol. (See attached reproducer)

      I am getting following error on spring-boot:

      Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
      2018-11-29 14:32:13.213 ERROR 26059 --- [           main] o.s.boot.SpringApplication               : Application startup failed
      
      org.apache.camel.RuntimeCamelException: java.lang.RuntimeException: java.net.BindException: Address already in use
              at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136) ~[camel-spring-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:174) ~[camel-spring-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
              at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
              at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) ~[spring-context-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) ~[spring-context-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) ~[spring-context-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
              at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.16.RELEASE.jar!/:1.5.16.RELEASE]
              at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.16.RELEASE.jar!/:1.5.16.RELEASE]
              at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.16.RELEASE.jar!/:1.5.16.RELEASE]
              at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.16.RELEASE.jar!/:1.5.16.RELEASE]
              at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.16.RELEASE.jar!/:1.5.16.RELEASE]
              at org.apache.camel.rest.Main.main(Main.java:12) [classes!/:na]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
              at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
              at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [rest-reproducer-1.0-SNAPSHOT.jar:na]
              at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [rest-reproducer-1.0-SNAPSHOT.jar:na]
              at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [rest-reproducer-1.0-SNAPSHOT.jar:na]
              at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [rest-reproducer-1.0-SNAPSHOT.jar:na]
      Caused by: java.lang.RuntimeException: java.net.BindException: Address already in use
              at io.undertow.Undertow.start(Undertow.java:249) ~[undertow-core-1.4.25.Final.jar!/:1.4.25.Final]
              at org.apache.camel.component.undertow.DefaultUndertowHost.registerHandler(DefaultUndertowHost.java:96) ~[camel-undertow-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.component.undertow.UndertowComponent.registerEndpoint(UndertowComponent.java:340) ~[camel-undertow-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.component.undertow.UndertowConsumer.doStart(UndertowConsumer.java:80) ~[camel-undertow-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.startService(DefaultCamelContext.java:3703) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRouteConsumers(DefaultCamelContext.java:4021) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.doStartRouteConsumers(DefaultCamelContext.java:3956) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3876) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3640) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3492) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3251) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3247) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3270) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3247) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3163) ~[camel-core-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133) ~[camel-spring-2.21.0.fuse-720050-redhat-00001.jar!/:2.21.0.fuse-720050-redhat-00001]
              ... 22 common frames omitted
      Caused by: java.net.BindException: Address already in use
              at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_181]
              at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_181]
              at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_181]
              at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_181]
              at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_181]
              at org.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:190) ~[xnio-nio-3.3.8.Final.jar!/:3.3.8.Final]
              at org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:243) ~[xnio-api-3.3.8.Final.jar!/:3.3.8.Final]
              at io.undertow.protocols.ssl.UndertowXnioSsl.createSslConnectionServer(UndertowXnioSsl.java:301) ~[undertow-core-1.4.25.Final.jar!/:1.4.25.Final]
              at io.undertow.Undertow.start(Undertow.java:234) ~[undertow-core-1.4.25.Final.jar!/:1.4.25.Final]
              ... 40 common frames omitted
      

      The problem is on line https://github.com/apache/camel/blob/master/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowComponent.java#L334. Spring-boot application creates new UndertowHost even if suitable host is present.

      When I bypass this behavior both endpoints (swagger and the REST one) are working.

              acosenti Andrea Cosentino
              jbouska@redhat.com Jan Bouska
              Jan Bouska Jan Bouska
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: