camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-8793) Deadlock between Spring and SpringCamelContext
Date Tue, 29 Sep 2015 07:14:04 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-8793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14934769#comment-14934769
] 

Claus Ibsen commented on CAMEL-8793:
------------------------------------

You should ideally add the routes the standard way. Or add them after Camel has started.

> Deadlock between Spring and SpringCamelContext
> ----------------------------------------------
>
>                 Key: CAMEL-8793
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8793
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-spring
>    Affects Versions: 2.15.2
>         Environment: Spring 4.1.5.RELEASE
>            Reporter: Mateusz Nowakowski
>
> Scenario:
> - used  Camel spring with <camelContext id="flows" xmlns="http://camel.apache.org/schema/spring"
/>
> - camelContext is used by some internal bean to expose an api to register routes for
other thread
> - Spring hasn't finished  initializing beans from the spring context contains Spring
Camel context
> - different thread starts using an api - calling indirectly Spring Camel context to register
routes
> - Camel context in order to add route get locks: camel context, spring singleton lock
(due to spring registry), but initial thread starting Spring context get lock: spring singleton
lock, camel context... causing deadlock.
> Workaround:
> - create and start DefaultCamelContext without Spring Registry.
> {code}
> Found one Java-level deadlock:
> =============================
> "localhost-startStop-6":
>   waiting to lock monitor 0xf350f544 (object 0x7e04a668, a org.apache.camel.spring.SpringCamelContext),
>   which is held by "lifecycleWorker6"
> "lifecycleWorker6":
>   waiting to lock monitor 0xf33ecc84 (object 0x7f01dc70, a java.util.concurrent.ConcurrentHashMap),
>   which is held by "localhost-startStop-6"
> Java stack information for the threads listed above:
> ===================================================
> "localhost-startStop-6":
> 	at org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:767)
> 	- waiting to lock <0x7e04a668> (a org.apache.camel.spring.SpringCamelContext)
> 	at org.apache.camel.builder.RouteBuilder.populateRoutes(RouteBuilder.java:397)
> 	at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:311)
> 	at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:731)
> 	at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:728)
> 	at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
> 	at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:728)
> 	at com.blablabla.BlaBlaRegistrar.registerBlaBlas(BlaBlaRegistrar.java:50)	
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
> 	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
> 	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1558)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
> 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
> 	- locked <0x7f01dc70> (a java.util.concurrent.ConcurrentHashMap)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
> 	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
> 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
> 	- locked <0x7d8b79b0> (a java.lang.Object)
> 	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
> 	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
> 	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
> 	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
> 	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
> 	- locked <0x7b9bde78> (a org.apache.catalina.core.StandardContext)
> 	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> 	- locked <0x7b9bde78> (a org.apache.catalina.core.StandardContext)
> 	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
> 	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
> 	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
> 	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
> 	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> 	at java.lang.Thread.run(Thread.java:722)
> "lifecycleWorker6":
> 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:188)
> 	- waiting to lock <0x7f01dc70> (a java.util.concurrent.ConcurrentHashMap)
> 	at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:487)
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:436)
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:412)
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:519)
> 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:512)
> 	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1052)
> 	at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:228)
> 	at org.apache.camel.spring.spi.ApplicationContextRegistry.findByTypeWithName(ApplicationContextRegistry.java:85)
> 	at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.findByTypeWithName(PropertyPlaceholderDelegateRegistry.java:70)
> 	at org.apache.camel.processor.interceptor.DefaultChannel.getOrCreateBacklogDebugger(DefaultChannel.java:372)
> 	at org.apache.camel.processor.interceptor.DefaultChannel.initChannel(DefaultChannel.java:235)
> 	at org.apache.camel.model.ProcessorDefinition.wrapChannel(ProcessorDefinition.java:273)
> 	at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:440)
> 	at org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:163)
> 	at org.apache.camel.model.OnExceptionDefinition.addRoutes(OnExceptionDefinition.java:193)
> 	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1025)
> 	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:185)
> 	at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:841)
> 	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2895)
> 	at org.apache.camel.impl.DefaultCamelContext.addRouteDefinitions(DefaultCamelContext.java:775)
> 	- locked <0x7e04a668> (a org.apache.camel.spring.SpringCamelContext)
> 	at org.apache.camel.builder.RouteBuilder.populateRoutes(RouteBuilder.java:397)
> 	at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:311)
> 	at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:731)
> 	at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:728)
> 	at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
> 	at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:728)
> 	at com.blablabla.BlaBlaRegistrar.registerBlaBlas(BlaBlaRegistrar.java:50)
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> 	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> 	at java.lang.Thread.run(Thread.java:722)
> Found 1 deadlock.
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message