Bug 1130880 - There is no way to switch TCCL for MQTT consumer execution
Summary: There is no way to switch TCCL for MQTT consumer execution
Keywords:
Status: MODIFIED
Alias: None
Product: JBoss Fuse Service Works 6
Classification: JBoss
Component: Camel
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Nobody
QA Contact: Matej Melko
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-18 06:18 UTC by Tomohisa Igarashi
Modified: 2021-10-15 11:52 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Apache JIRA CAMEL-7722 0 None None None Never
Apache JIRA CAMEL-7728 0 None None None Never
Red Hat Issue Tracker SWITCHYARD-2220 0 Major Resolved Unable to find BeanManager error on executing mqtt quickstart on karaf 2018-06-11 14:12:34 UTC

Description Tomohisa Igarashi 2014-08-18 06:18:28 UTC
A BeanManager not found error is thrown when it executes camel-mqtt-binding quickstart on karaf. I think this can be avoid if we just switch the TCCL to the OSGi bundle class loader, but there is no way to switch TCCL for MQTT consumer execution right now.

If camel-mqtt accept switching TCCL here, I think it can be solved.
https://github.com/apache/camel/blob/master/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java#L86


Stacktrace:
java.lang.IllegalStateException: Unable to find BeanManager. Please ensure that you configured the CDI implementation of your choice properly.
        at org.apache.deltaspike.core.api.provider.BeanManagerProvider.getBeanManager(BeanManagerProvider.java:194)[104:org.apache.deltaspike.core.deltaspike-core-api:0.4.0]
        at org.apache.deltaspike.core.api.provider.BeanProvider.getBeanManager(BeanProvider.java:446)[104:org.apache.deltaspike.core.deltaspike-core-api:0.4.0]
        at org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference(BeanProvider.java:117)[104:org.apache.deltaspike.core.deltaspike-core-api:0.4.0]
        at org.apache.camel.cdi.CdiInjector.newInstance(CdiInjector.java:44)[105:org.apache.camel.camel-cdi:2.12.2]
        at org.apache.camel.impl.osgi.Activator$BaseResolver.createInstance(Activator.java:402)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.impl.osgi.Activator$BaseResolver.createInstance(Activator.java:390)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.impl.osgi.Activator$BundleLanguageResolver.resolveLanguage(Activator.java:212)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.core.osgi.OsgiLanguageResolver.getLanguage(OsgiLanguageResolver.java:75)[177:org.switchyard.karaf.switchyard-karaf-deploy:2.0.0.SNAPSHOT]
        at org.apache.camel.core.osgi.OsgiLanguageResolver.resolveLanguage(OsgiLanguageResolver.java:55)[177:org.switchyard.karaf.switchyard-karaf-deploy:2.0.0.SNAPSHOT]
        at org.apache.camel.impl.DefaultCamelContext.resolveLanguage(DefaultCamelContext.java:1050)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.builder.SimpleBuilder.createExpression(SimpleBuilder.java:98)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.builder.SimpleBuilder.evaluate(SimpleBuilder.java:81)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.builder.ProcessorBuilder$7.process(ProcessorBuilder.java:162)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)[61:org.apache.camel.camel-core:2.12.2]
        at org.apache.camel.component.mqtt.MQTTConsumer.processExchange(MQTTConsumer.java:46)[191:org.apache.camel.camel-mqtt:2.12.2]
        at org.apache.camel.component.mqtt.MQTTEndpoint$1.onPublish(MQTTEndpoint.java:90)[191:org.apache.camel.camel-mqtt:2.12.2]
        at org.fusesource.mqtt.client.CallbackConnection.toReceiver(CallbackConnection.java:815)[187:org.fusesource.mqtt-client.mqtt-client:1.6]
        at org.fusesource.mqtt.client.CallbackConnection.processFrame(CallbackConnection.java:732)[187:org.fusesource.mqtt-client.mqtt-client:1.6]
        at org.fusesource.mqtt.client.CallbackConnection.access$1500(CallbackConnection.java:51)[187:org.fusesource.mqtt-client.mqtt-client:1.6]
        at org.fusesource.mqtt.client.CallbackConnection$6.onTransportCommand(CallbackConnection.java:392)[187:org.fusesource.mqtt-client.mqtt-client:1.6]
        at org.fusesource.hawtdispatch.transport.TcpTransport.drainInbound(TcpTransport.java:664)[189:org.fusesource.hawtdispatch.hawtdispatch-transport:1.18.0]
        at org.fusesource.hawtdispatch.transport.TcpTransport$6.run(TcpTransport.java:543)[189:org.fusesource.hawtdispatch.hawtdispatch-transport:1.18.0]
        at org.fusesource.hawtdispatch.internal.NioDispatchSource$3.run(NioDispatchSource.java:209)[188:org.fusesource.hawtdispatch.hawtdispatch:1.18.0]
        at org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:100)[188:org.fusesource.hawtdispatch.hawtdispatch:1.18.0]
        at org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77)[188:org.fusesource.hawtdispatch.hawtdispatch:1.18.0]

Comment 1 Tomohisa Igarashi 2014-08-19 09:07:39 UTC
I think the root cause of this issue is CAMEL-7722. The camel-mqtt consumer executing thread should have BundleDelegatingClassLoader as a TCCL, but it seems there is no configuration point to achieve it like setting TCCL or pass a custom ThreadPool.

Comment 2 Tomohisa Igarashi 2014-08-21 04:09:10 UTC
Willem found another idea to cover this problem - it will be addressed by CAMEL-7728.

Comment 3 Tomohisa Igarashi 2014-08-28 12:18:44 UTC
Updates (copied same comment from SWITCHYARD-2220):

CAMEL-7728 helps to solve this issue, but not enough. Since applicationContextClassLoader in the CamelContext is not initialized with bundle deployment class loader by default, CAMEL-7728 causes "Unable to find BeanManager" issue at another place. We need to set bundle deployment class loader as a applicationContextClassLoader manually:
https://github.com/igarashitm/core/tree/SWITCHYARD-2220
This fix will be unnecessary once CAMEL-7759 is merged though.

And we also need to set TCCL manually in the MQTT inbound route:
https://github.com/igarashitm/components/tree/SWITCHYARD-2220

Then finally the camel-mqtt-binding quickstart works. We also need a following tweak to test it out.
https://github.com/igarashitm/quickstarts/tree/SWITCHYARD-2220

However, then I hit SWITCHYARD-2299. I won't be able to issue PRs until SWITCHYARD-2299 is fixed.

Comment 4 Tomohisa Igarashi 2014-08-28 21:34:58 UTC
Sent PRs. The fixes for CAMEL-7728 and SWITCHYARD-2220 should solve this issue.

Comment 5 Rob Cernich 2014-09-03 01:04:37 UTC
Changing back to ASSIGNED as this also requires an upstream fix in camel.  Once that is complete, we will need to make sure we get the correct camel version aligned with the release.

Comment 6 Tomohisa Igarashi 2014-09-03 01:18:29 UTC
Assigning back to Kevin - Kevin, could you chase up who can maintain the camel product branch so CAMEL-7728 is merged into the version we'll have in FSW6.1?

Comment 7 vkasala 2014-09-04 09:21:09 UTC
A BeanManager not found error is thrown when it executes camel-mqtt-binding quickstart with message trace enabled on EAP_6.3.0.Beta + SY-2.0.Alpha2. It appears on EAP, but not 100%, intermittently.

To reproduce:
1. Enable message trace in switchyard.xml.
2. Deploy
3. Run MQTTClient multiple times.
 

Stacktrace:
14:13:56,257 WARNING [org.apache.deltaspike.core.api.provider.BeanManagerProvider] (hawtdispatch-DEFAULT-2) When using the BeanManager to retrieve Beans before the Container is started, non-portable behaviour results!                                                                 
14:13:56,262 ERROR [org.apache.camel.processor.DefaultErrorHandler] (hawtdispatch-DEFAULT-2) Failed delivery for (MessageId: ID-vkasala-ThinkPad-T440s-40791-1409660014827-3-1 on ExchangeId: ID-vkasala-ThinkPad-T440s-40791-1409660014827-3-2). Exhausted after delivery attempt: 1 caught: java.lang.IllegalStateException: Unable to find BeanManager. Please ensure that you configured the CDI implementation of your choice properly.                                          

Message History                                                                               
---------------------------------------------------------------------------------------------------------------------------------------                                                     
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)                                                     
[V1CamelMqttBinding] [V1CamelMqttBinding] [mqtt://Greet?password=xxxxxx&subscribeTopicName=camel%2Fmqtt%2Ftest%2Finput&us] [         7]                                                     
[V1CamelMqttBinding] [setProperty3      ] [setProperty[org.switchyard.exchangeGatewayName]                               ] [         5]                                                     

Exchange                                                                                      
---------------------------------------------------------------------------------------------------------------------------------------                                                     
Exchange[                                                                                     


amelRedelivered=false, CamelRedeliveryCounter=0}                                              


]                                                                                             

Stacktrace                                                                                    
---------------------------------------------------------------------------------------------------------------------------------------: java.lang.IllegalStateException: Unable to find BeanManager. Please ensure that you configured the CDI implementation of your choice properly.   
gerProvider.java:201) [deltaspike-core-api-0.5.jar:0.5]                                       
va:473) [deltaspike-core-api-0.5.jar:0.5]                                                     
vider.java:117) [deltaspike-core-api-0.5.jar:0.5]                                             

er.java:74) [camel-core-2.12.2.jar:2.12.2]                                                    
1050) [camel-core-2.12.2.jar:2.12.2]                                                          
el-core-2.12.2.jar:2.12.2]                                                                    
2.12.2.jar:2.12.2]                                                                            
el-core-2.12.2.jar:2.12.2]                                                                    
.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.12.2.jar:2.12.2]                
or.java:72) [camel-core-2.12.2.jar:2.12.2]                                                    
va:398) [camel-core-2.12.2.jar:2.12.2]                                                        
va:191) [camel-core-2.12.2.jar:2.12.2]                                                        
ar:2.12.2]                                                                                    
r:2.12.2]                                                                                     
va:191) [camel-core-2.12.2.jar:2.12.2]                                                        
camel-core-2.12.2.jar:2.12.2]                                                                 
va:87) [camel-core-2.12.2.jar:2.12.2]                                                         
[camel-mqtt-2.12.2.jar:2.12.2]                                                                
el-mqtt-2.12.2.jar:2.12.2]                                                                    
5) [mqtt-client-1.6.jar:1.6]                                                                  
732) [mqtt-client-1.6.jar:1.6]                                                                
1) [mqtt-client-1.6.jar:1.6]                                                                  
on.java:392) [mqtt-client-1.6.jar:1.6]                                                        
64) [hawtdispatch-transport-1.18.jar:1.18]                                                    
wtdispatch-transport-1.18.jar:1.18]                                                           
:209) [hawtdispatch-1.18.jar:1.18]                                                            
va:100) [hawtdispatch-1.18.jar:1.18]                                                          
awtdispatch-1.18.jar:1.18]                                                                    

14:13:56,266 WARN  [org.apache.camel.component.mqtt.MQTTConsumer] (hawtdispatch-DEFAULT-2) Error processing exchange.. Exchange[Message: Captain Crunch]. Caused by: [java.lang.IllegalStateException - Unable to find BeanManager. Please ensure that you configured the CDI implementation of your choice properly.]: java.lang.IllegalStateException: Unable to find BeanManager. Please ensure that you configured the CDI implementation of your choice properly.                
gerProvider.java:201) [deltaspike-core-api-0.5.jar:0.5]                                       
va:473) [deltaspike-core-api-0.5.jar:0.5]                                                     
vider.java:117) [deltaspike-core-api-0.5.jar:0.5]                                             

er.java:74) [camel-core-2.12.2.jar:2.12.2]                                                    
1050) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.builder.SimpleBuilder.createExpression(SimpleBuilder.java:98) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.builder.SimpleBuilder.evaluate(SimpleBuilder.java:81) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.builder.ProcessorBuilder$7.process(ProcessorBuilder.java:162) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87) [camel-core-2.12.2.jar:2.12.2]
        at org.apache.camel.component.mqtt.MQTTConsumer.processExchange(MQTTConsumer.java:46) [camel-mqtt-2.12.2.jar:2.12.2]
        at org.apache.camel.component.mqtt.MQTTEndpoint$1.onPublish(MQTTEndpoint.java:90) [camel-mqtt-2.12.2.jar:2.12.2]
        at org.fusesource.mqtt.client.CallbackConnection.toReceiver(CallbackConnection.java:815) [mqtt-client-1.6.jar:1.6]
        at org.fusesource.mqtt.client.CallbackConnection.processFrame(CallbackConnection.java:732) [mqtt-client-1.6.jar:1.6]
        at org.fusesource.mqtt.client.CallbackConnection.access$1500(CallbackConnection.java:51) [mqtt-client-1.6.jar:1.6]
        at org.fusesource.mqtt.client.CallbackConnection$6.onTransportCommand(CallbackConnection.java:392) [mqtt-client-1.6.jar:1.6]
        at org.fusesource.hawtdispatch.transport.TcpTransport.drainInbound(TcpTransport.java:664) [hawtdispatch-transport-1.18.jar:1.18]
        at org.fusesource.hawtdispatch.transport.TcpTransport$6.run(TcpTransport.java:543) [hawtdispatch-transport-1.18.jar:1.18]
        at org.fusesource.hawtdispatch.internal.NioDispatchSource$3.run(NioDispatchSource.java:209) [hawtdispatch-1.18.jar:1.18]
        at org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:100) [hawtdispatch-1.18.jar:1.18]
        at org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77) [hawtdispatch-1.18.jar:1.18]

Comment 8 kconner 2015-02-02 23:55:45 UTC
Changing to MODIFIED as the Camel issue is now also marked as resolved.


Note You need to log in before you can comment on or make changes to this bug.