Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-18089

camel-spring-boot - IllegalThreadStateException when trying to resume suspended Camel context

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.7.1, 3.16.0
    • 3.17.0
    • camel-spring-boot
    • None
    • Unknown

    Description

      Resuming a suspended camel context results in an IllegalThreadStateException. 

      When all routes and the context are started, calling camelContext.suspend(); or clicking 'Suspend' in hawtio will suspend the context and the routes, showing them as 'Suspended' in hawtio.

      Then, calling camelContext.resume(); or clicking 'Start' on the Context in hawtio, will throw an IllegalThreadStateException and afterwards the context is in state 'stopped'. There seems to be no way to restart the context other than restarting the whole application. 

      Tried this with our actual application:

      • Java 14.0.2
      • Camel 3.7.1
      • Spring Boot 2.4.2
      • Jolokia 1.6.2
      • hawtio 2.13.3

      And also with a little test application with different dependency versions and only a simple test route, the result was the same.

      • Java 17.0.1 (also tried with 11.0.6 and 14.0.2, same result)
      • Camel 3.16.0
      • Spring Boot 2.6.6
      • Jolokia 1.7.1
      • hawtio 2.14.5

      Stacktrace:

       

      o.a.camel.support.service.BaseService    : Error while resuming service: SpringCamelContext(CamelTestContext) with spring id applicationjava.lang.IllegalThreadStateException: null
          at java.base/java.lang.Thread.start(Thread.java:793) ~[na:na]
          at org.apache.camel.spring.boot.CamelMainRunController.start(CamelMainRunController.java:40) ~[camel-spring-boot-3.16.0.jar:3.16.0]
          at org.apache.camel.spring.boot.CamelSpringBootApplicationListener$1.onCamelContextStarted(CamelSpringBootApplicationListener.java:148) ~[camel-spring-boot-3.16.0.jar:3.16.0]
          at org.apache.camel.impl.engine.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:196) ~[camel-base-engine-3.16.0.jar:3.16.0]
          at org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRoutes(InternalRouteStartupManager.java:147) ~[camel-base-engine-3.16.0.jar:3.16.0]
          at org.apache.camel.impl.engine.AbstractCamelContext.doResume(AbstractCamelContext.java:2585) ~[camel-base-engine-3.16.0.jar:3.16.0]
          at org.apache.camel.support.service.BaseService.resume(BaseService.java:214) ~[camel-api-3.16.0.jar:3.16.0]
          at org.apache.camel.management.mbean.ManagedCamelContext.start(ManagedCamelContext.java:292) ~[camel-management-3.16.0.jar:3.16.0]
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
          at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
          at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:72) ~[na:na]
          at jdk.internal.reflect.GeneratedMethodAccessor43.invoke(Unknown Source) ~[na:na]
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
          at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
          at java.base/sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:262) ~[na:na]
          at java.management/javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1178) ~[na:na]
          at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) ~[na:na]
          at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) ~[na:na]
          at java.management/javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1172) ~[na:na]
          at java.management/javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1016) ~[na:na]
          at org.apache.camel.support.management.MixinRequiredModelMBean.invoke(MixinRequiredModelMBean.java:72) ~[camel-support-3.16.0.jar:3.16.0]
          at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:814) ~[na:na]
          at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802) ~[na:na]
          at org.jolokia.handler.ExecHandler.doHandleRequest(ExecHandler.java:98) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.handler.ExecHandler.doHandleRequest(ExecHandler.java:40) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.handler.JsonRequestHandler.handleRequest(JsonRequestHandler.java:89) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.backend.MBeanServerExecutorLocal.handleRequest(MBeanServerExecutorLocal.java:109) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.backend.MBeanServerHandler.dispatchRequest(MBeanServerHandler.java:161) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.backend.LocalRequestDispatcher.dispatchRequest(LocalRequestDispatcher.java:99) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.backend.BackendManager.callRequestDispatcher(BackendManager.java:429) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.backend.BackendManager.handleRequest(BackendManager.java:158) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.http.HttpRequestHandler.executeRequest(HttpRequestHandler.java:197) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.http.HttpRequestHandler.handlePostRequest(HttpRequestHandler.java:131) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.http.AgentServlet$3.handleRequest(AgentServlet.java:493) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.http.AgentServlet.handleSecurely(AgentServlet.java:383) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.http.AgentServlet.handle(AgentServlet.java:354) ~[jolokia-core-1.7.1.jar:na]
          at org.jolokia.http.AgentServlet.doPost(AgentServlet.java:317) ~[jolokia-core-1.7.1.jar:na]
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:681) ~[tomcat-embed-core-9.0.60.jar:4.0.FR]
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.60.jar:4.0.FR]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.18.jar:5.3.18]
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.18.jar:5.3.18]
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96) ~[spring-boot-actuator-2.6.6.jar:2.6.6]
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.18.jar:5.3.18]
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
          at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na] 

      Dependencies:

       

      <properties>
          <java.version>17</java.version>
          <jolokia-core.version>1.7.1</jolokia-core.version>
          <camel-version>3.16.0</camel-version>
      </properties>
      <dependencies>
          <dependency>
              <groupId>org.apache.camel.springboot</groupId>
              <artifactId>camel-spring-boot-starter</artifactId>
              <version>3.16.0</version>
          </dependency>    
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-test</artifactId>
              <scope>test</scope>
          </dependency>    
          <dependency>
              <groupId>org.apache.camel.springboot</groupId>
              <artifactId>camel-file-starter</artifactId>
              <version>${camel-version}</version>
          </dependency>
          <dependency>
              <groupId>org.apache.camel</groupId>
              <artifactId>camel-management</artifactId>
              <version>${camel-version}</version>
          </dependency>
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-web</artifactId>
          </dependency>
          <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-actuator</artifactId>
          </dependency>
          <dependency>
              <groupId>org.jolokia</groupId>
              <artifactId>jolokia-core</artifactId>
              <version>${jolokia-core.version}</version>
          </dependency>
      </dependencies> 

      The test route:

       

      public class MyRouteBuilder extends RouteBuilder {    
          @Override
          public void configure() throws Exception {
              from("file:src/data?noop=true")
                      .routeId("ROUTE1")
                      .log(LoggingLevel.INFO, "ROUTE1 entered")
                      .to("file://target/test");
          }
      } 

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            davsclaus Claus Ibsen
            cebra Rebecca
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment