In the end, the solution was to replace

<to uri="bean:myBean" />

with

<bean ref="myBean" />

This way, the bean is still referencend and can be called while the other
context is shutting down.

- Martin


Martin Lichtin-2 wrote
> This didn't make a difference.
> 
> However, something else I noticed. There is a second CamelContext defined
> in the same Blueprint file.
> This Camel context is shutdown first.
> As it contains a from(jms:) endpoint, the shutdown takes a few secs (and
> that's why the timer-based route in the "myRouteContext" context can still
> fire a timer).
> 
> This second Camel context seems to influence the one that's then having
> the bean lookup issue.
> As soon as I comment out that 2nd context, the NoSuchBeanException
> disappears.
> 
> On 27.05.2015 08:39, Claus Ibsen wrote:
>> Try remove the depends-on, not sure if blueprint shutdown in reverse
>> order and therefore the bean before camel etc.
>>
>> On Tue, May 26, 2015 at 9:56 PM, Martin Lichtin
>> &lt;

> [email protected]

> &gt; wrote:
>>> Using Blueprint in an OSGi bundle:
>>>
>>>      
> <bean id="myBean" init-method="init" destroy-method="destroy"
>>
>> class="myPkg.MyBean">
>>>      
> </bean>
>>>
>>>      
> <camelContext xmlns="http://camel.apache.org/schema/blueprint";
>>
>> xsi:schemaLocation="http://camel.apache.org/schema/blueprint
>>> http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";
>>>          id="myRouteContext" depends-on="myBean">
>>>          
> <route id="myTimer">
>>>              
> <from uri="timer://myTimer?fixedRate=true&amp;period=2000" />
>>>              
> <to uri="bean:myBean" />
>>>          
> </route>
>>>      
> </camelContext>
>>>
>>> The issue seems to have started popping up after upgrading to Camel
>>> 2.15.x.
>>>
>>> On 26.05.2015 14:14, Claus Ibsen wrote:
>>>> Hi
>>>>
>>>> Are you using a spring xml file? Then its spring app context that is
>>>> the registry. Camel does not remove any beans from it. Its spring that
>>>> does that. So maybe you have some depends-on spring attribute order
>>>> wrong or something.
>>>>
>>>> On Tue, May 26, 2015 at 12:41 PM, Martin Lichtin
>>>> &lt;

> [email protected]

> &gt; wrote:
>>>>> Is anyone else seeing this issue on shutting down a simple timer-based
>>>>> route such as
>>>>>
>>>>> 
> <route id=myRoute">
>>>>>                           
> <from
>>
>>>> uri=timer://myTimer?fixedRate=true&amp;period 00" />
>>>>>                           
> <to uri=bean:myBean" />
>>>>> 
> </route>
>>>>>
>>>>> On shutting down, it reports
>>>>>
>>>>> 2015-05-22 01:20:14,970 | INFO  | FelixStartLevel          |
>>>>> DefaultShutdownStrategy          | mel.impl.DefaultShutdownStrategy 
>>>>> 184 |
>>>>> 94 - org.apache.camel.camel-core - 2.15.1 | Starting to graceful
>>>>> shutdown 1
>>>>> routes (timeout 300 seconds)
>>>>> 2015-05-22 01:20:16,634 | WARN  | timer://myRoute | TimerConsumer
>>>>> | rg.apache.camel.util.CamelLogger  224 | 94 -
>>>>> org.apache.camel.camel-core -
>>>>> 2.15.1 | Error processing exchange. Exchange[Message: [Body is null]].
>>>>> Caused by: [org.apache.camel.NoSuchBeanException - No bean could be
>>>>> found in
>>>>> the registry for: myBean]
>>>>> org.apache.camel.NoSuchBeanException: No bean could be found in the
>>>>> registry for: myBean
>>>>> at
>>>>> org.apache.camel.component.bean.RegistryBean.getBean(RegistryBean.java:85)[94:org.apache.camel.camel-core:2.15.1]
>>>>> at
>>>>> org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:78)[94:org.apache.camel.camel-core:2.15.1]
>>>>>
>>>>>
>>>>> I have double-checked that bean "myBean" is still around at this point
>>>>> in
>>>>> time.
>>>>> It seems perhaps the bean is prematurely removed from the registry?
>>>>> Or the timer for some reason fires even though the route is in the
>>>>> middle
>>>>> shutting down?
>>>>>
>>>>> - Martin
>>
>>





--
View this message in context: 
http://camel.465427.n5.nabble.com/Issue-with-timer-route-NoSuchBeanException-on-route-shutdown-tp5767470p5767649.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to