Forum Home » Enterprise Products » Fuse ESB Enterprise

Thread: Exception org.apache.camel.NoSuchBeanException thrown while stopping bundle

 
This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Aug 17, 2012 12:48 PM Last Post By: davsclaus Threads: [ Previous | Next ]
tnk

Posts: 11
Registered: 02/28/11
Exception org.apache.camel.NoSuchBeanException thrown while stopping bundle
Posted: Aug 17, 2012 8:52 AM
 
  Click to reply to this thread Reply
Hello,

it seems, that the order of defining beans in spring matters. With the following configuration, when the bundle is being stopped, I got exception:

Could not unregister error handler: org.apache.camel.management.mbean.ManagedErrorHandler@427a0b as ErrorHandler MBean.
org.apache.camel.NoSuchBeanException: Cannot lookup: testErrorHandler from registry: org.apache.camel.spring.spi.ApplicationContextRegistry@b1e15c with expec- 2.9.
ted type: interface org.apache.camel.builder.ErrorHandlerBuilder due: Error creating bean with name 'testErrorHandler': Singleton bean creation not allowed w
hile the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)

Spring context:

<camel-osgi:camelContext id="test-context" xmlns="http://camel.apache.org/schema/spring">
<route id="test-route" errorHandlerRef="testErrorHandler">
<from uri="jetty:http://0.0.0.0/test" />
<to uri="log:TEST?showAll=true" />
</route>
</camel-osgi:camelContext>
<bean id="testErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
<property name="deadLetterUri" value="mock:dead" />
</bean>

But if I define testErrorHandler bean before camel context, bundle is stopped without any exceptions:

<bean id="testErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
<property name="deadLetterUri" value="mock:dead" />
</bean>

<camel-osgi:camelContext id="test-context" xmlns="http://camel.apache.org/schema/spring">
<route id="test-route" errorHandlerRef="testErrorHandler">
<from uri="jetty:http://0.0.0.0/test" />
<to uri="log:TEST?showAll=true" />
</route>
</camel-osgi:camelContext>

Is it a bug? There were no issues with previous version (apache-servicemix-4.3.1-fuse).

Tested with fuse-esb-7.0.0.fuse-061

davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Exception org.apache.camel.NoSuchBeanException thrown while stopping bundle
Posted: Aug 17, 2012 12:47 PM   in response to: tnk in response to: tnk
 
  Click to reply to this thread Reply
Use the <errorHandler> inside the <camelContext> to configure your error handler. Then you dont need the <bean> tag.
http://camel.apache.org/error-handler.html
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Exception org.apache.camel.NoSuchBeanException thrown while stopping bundle
Posted: Aug 17, 2012 12:48 PM   in response to: davsclaus in response to: davsclaus
 
  Click to reply to this thread Reply
If you want to keep using the <bean> then you may need to declare a depends-on="test-context" as attribute on <bean> so Spring knows it depends on Camel, and can better shutdown orderly.