Uploaded image for project: 'ServiceMix 4'
  1. ServiceMix 4
  2. SMX4-966

Connection refused to embedded broker when starting up

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.4.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Ubuntu Natty, OSX Lion, Servicemix 4.4.1

    • Patch Info:
      Patch Available

      Description

      The exception below is thrown in the console when Smx is started up. This is being caused by the ConnectionFactory defined in activemq-broker.xml starting before the broker. Running an update on the activemq-broker.xml bundle verifies that this bundle is the cause. It can be gotten around by adding an id to the broker and adding a depends-on attribute to the ConnectionFactory bean definition.

      karaf@root> ERROR: Bundle org.apache.servicemix.jbi.osgi [151] EventDispatcher: Error during dispatch. (org.apache.servicemix.nmr.api.ServiceMixException: Unable to register service servicemix-wsn2005 with properties

      {NAME=servicemix-wsn2005, objectClass=[Ljava.lang.String;@694d91, service.id=454, TYPE=service-engine}. Reason: javax.jbi.JBIException: Error calling init)
      org.apache.servicemix.nmr.api.ServiceMixException: Unable to register service servicemix-wsn2005 with properties {NAME=servicemix-wsn2005, objectClass=[Ljava.lang.String;@694d91, service.id=454, TYPE=service-engine}

      . Reason: javax.jbi.JBIException: Error calling init
      at org.apache.servicemix.nmr.core.ServiceRegistryImpl.register(ServiceRegistryImpl.java:52)
      at org.apache.servicemix.nmr.osgi.OsgiServiceRegistryTracker.addingService(OsgiServiceRegistryTracker.java:78)
      at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896)
      at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
      at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
      at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840)
      at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859)
      at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721)
      at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649)
      at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781)
      at org.apache.felix.framework.Felix.access$000(Felix.java:79)
      at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723)
      at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107)
      at org.apache.felix.framework.Felix.registerService(Felix.java:2870)
      at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
      at org.apache.servicemix.jbi.deployer.impl.Deployer.registerService(Deployer.java:758)
      at org.apache.servicemix.jbi.deployer.impl.Deployer.registerComponent(Deployer.java:414)
      at org.apache.servicemix.jbi.deployer.impl.ComponentInstaller.initComponent(ComponentInstaller.java:424)
      at org.apache.servicemix.jbi.deployer.impl.ComponentInstaller.install(ComponentInstaller.java:150)
      at org.apache.servicemix.jbi.deployer.impl.Deployer.registerDeployedComponent(Deployer.java:653)
      at org.apache.servicemix.jbi.deployer.impl.Deployer$1.addingService(Deployer.java:218)
      at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896)
      at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
      at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
      at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840)
      at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859)
      at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721)
      at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649)
      at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781)
      at org.apache.felix.framework.Felix.access$000(Felix.java:79)
      at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723)
      at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107)
      at org.apache.felix.framework.Felix.registerService(Felix.java:2870)
      at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:404)
      at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:184)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.notifySatisfaction(BlueprintContainerImpl.java:612)
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.setSatisfied(AbstractServiceReferenceRecipe.java:305)
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceAdded(AbstractServiceReferenceRecipe.java:262)
      at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceChanged(AbstractServiceReferenceRecipe.java:245)
      at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859)
      at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721)
      at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649)
      at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781)
      at org.apache.felix.framework.Felix.access$000(Felix.java:79)
      at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723)
      at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107)
      at org.apache.felix.framework.Felix.registerService(Felix.java:2870)
      at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:404)
      at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:184)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerServices(BlueprintContainerImpl.java:662)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:330)
      at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227)
      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.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:679)
      Caused by: javax.jbi.JBIException: Error calling init
      at org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:211)
      at org.apache.servicemix.jbi.deployer.artifacts.ComponentImpl$ComponentWrapper.init(ComponentImpl.java:247)
      at org.apache.servicemix.jbi.runtime.impl.ComponentRegistryImpl.doRegister(ComponentRegistryImpl.java:88)
      at org.apache.servicemix.jbi.runtime.impl.ComponentRegistryImpl.doRegister(ComponentRegistryImpl.java:37)
      at org.apache.servicemix.nmr.core.ServiceRegistryImpl.register(ServiceRegistryImpl.java:47)
      ... 61 more
      Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused
      at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
      at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:290)
      at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:234)
      at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:182)
      at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:137)
      at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:121)
      at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:92)
      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:616)
      at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)
      at org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31)
      at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
      at $Proxy67.createConnection(Unknown Source)
      at org.apache.servicemix.wsn.jms.JmsNotificationBroker.init(JmsNotificationBroker.java:48)
      at org.apache.servicemix.wsn.component.WSNComponent.doInit(WSNComponent.java:165)
      at org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:205)
      ... 65 more
      Caused by: java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
      at java.net.Socket.connect(Socket.java:546)
      at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:505)
      at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:468)
      at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:54)
      at org.apache.activemq.transport.InactivityMonitor.start(InactivityMonitor.java:126)
      at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
      at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72)
      at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
      at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
      at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:270)
      ... 81 more

        Activity

        Show
        ffang Freeman Fang added a comment - commit fix http://svn.apache.org/viewvc?rev=1202048&view=rev
        Hide
        ffang Freeman Fang added a comment -

        Thanks guys.

        @Gert,
        Use failover:(tcp://localhost:61616) works when restart SMX, but still get errors when refresh/update activemq-broker.xml bundle, the bundle status is always "Creating" which indicate not start completely and then the smx hang so that we can't shutdown it from the console, I figured out the root cause is that the servicemix-wsn2005 component bundle can't restart correctly when refresh/update activemq-broker.xml bundle, it's also the same reason why I saw exceptions when I use vm://default?create=false&waitForStart=10000
        SMXCOMP-914[1] could fix it in servicemix-wsn2005, so I will use vm://default?create=false&waitForStart=10000 as it's faster and it works for both cases(restart SMX or restart activemq-broker.xml bundle)by my test.
        [1]https://issues.apache.org/jira/browse/SMXCOMP-914

        @Gary,
        Thanks for clarification, yes, we have attribute brokerName="default" for <broker..
        so "default" is ok here, also the vm... is in the same bundle with broker creation to expose ConnectionFactory, so I believe vm... is also OK here, .

        Best Regards
        Freeman

        Show
        ffang Freeman Fang added a comment - Thanks guys. @Gert, Use failover:(tcp://localhost:61616) works when restart SMX, but still get errors when refresh/update activemq-broker.xml bundle, the bundle status is always "Creating" which indicate not start completely and then the smx hang so that we can't shutdown it from the console, I figured out the root cause is that the servicemix-wsn2005 component bundle can't restart correctly when refresh/update activemq-broker.xml bundle, it's also the same reason why I saw exceptions when I use vm://default?create=false&waitForStart=10000 SMXCOMP-914 [1] could fix it in servicemix-wsn2005, so I will use vm://default?create=false&waitForStart=10000 as it's faster and it works for both cases(restart SMX or restart activemq-broker.xml bundle)by my test. [1] https://issues.apache.org/jira/browse/SMXCOMP-914 @Gary, Thanks for clarification, yes, we have attribute brokerName="default" for <broker.. so "default" is ok here, also the vm... is in the same bundle with broker creation to expose ConnectionFactory, so I believe vm... is also OK here, . Best Regards Freeman
        Hide
        gertvanthienen Gert Vanthienen added a comment -

        Ordering the startup of the broker and the connection factory (e.g. using an AtomicReference to wrap the broker and then using the depends-on on the connection factory) seems to fix the issue for both the vm: and the tcp: protocol exceptions - it looks like we need to take a look at the blueprint broker bean definition parser to ensure we don't need that kind of hack.

        One thing though - even when the order is correct, I still see another exception when doing an osgi:update for the activemq-broker.xml configuration

        20:26:10,807 | ERROR | rint Extender: 2 | BrokerService                    | 45 - org.apache.activemq.activemq-core - 5.5.1.fuse-01-06 | Failed to start ActiveMQ JMS Message Broker (default, null). Reason: javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=default,Type=Broker
        javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=default,Type=Broker
        	at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)[:1.6.0_29]
        	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)[:1.6.0_29]
        	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)[:1.6.0_29]
        	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)[:1.6.0_29]
        	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)[:1.6.0_29]
        	at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)[:1.6.0_29]
        	at org.apache.activemq.broker.jmx.ManagementContext.registerMBean(ManagementContext.java:300)
                   ...
        

        In summary - I think there are two issues to be fixed here:

        • ensure the Blueprint namespace handler sets the id correctly to allow ordering
        • check on the shutdown behavior of the embedded broker created by the blueprint namespace handler

        In the meanwhile (e.g. for the upcoming 4.4.0 release), we could go for a failover:(tcp://localhost:61616) instead - that way, the exception is turned into a nice little warning instead

        20:32:45,397 | WARN  | /127.0.0.1:61616 | FailoverTransport                | ?                                   ? | 45 - org.apache.activemq.activemq-core - 5.5.1.fuse-01-06 | Transport (localhost/127.0.0.1:61616) failed, reason:  java.io.EOFException, attempting to automatically reconnect
        
        Show
        gertvanthienen Gert Vanthienen added a comment - Ordering the startup of the broker and the connection factory (e.g. using an AtomicReference to wrap the broker and then using the depends-on on the connection factory) seems to fix the issue for both the vm: and the tcp: protocol exceptions - it looks like we need to take a look at the blueprint broker bean definition parser to ensure we don't need that kind of hack. One thing though - even when the order is correct, I still see another exception when doing an osgi:update for the activemq-broker.xml configuration 20:26:10,807 | ERROR | rint Extender: 2 | BrokerService | 45 - org.apache.activemq.activemq-core - 5.5.1.fuse-01-06 | Failed to start ActiveMQ JMS Message Broker (default, null). Reason: javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=default,Type=Broker javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=default,Type=Broker at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)[:1.6.0_29] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)[:1.6.0_29] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)[:1.6.0_29] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)[:1.6.0_29] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)[:1.6.0_29] at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)[:1.6.0_29] at org.apache.activemq.broker.jmx.ManagementContext.registerMBean(ManagementContext.java:300) ... In summary - I think there are two issues to be fixed here: ensure the Blueprint namespace handler sets the id correctly to allow ordering check on the shutdown behavior of the embedded broker created by the blueprint namespace handler In the meanwhile (e.g. for the upcoming 4.4.0 release), we could go for a failover:(tcp://localhost:61616) instead - that way, the exception is turned into a nice little warning instead 20:32:45,397 | WARN | /127.0.0.1:61616 | FailoverTransport | ? ? | 45 - org.apache.activemq.activemq-core - 5.5.1.fuse-01-06 | Transport (localhost/127.0.0.1:61616) failed, reason: java.io.EOFException, attempting to automatically reconnect
        Hide
        jkorab Jakub Korab added a comment -

        @Freeman You're right, the Aries depends-on doesn't see that bean instance, whereas Spring would. I should have double-checked it.

        Show
        jkorab Jakub Korab added a comment - @Freeman You're right, the Aries depends-on doesn't see that bean instance, whereas Spring would. I should have double-checked it.
        Hide
        gtully Gary Tully added a comment - - edited

        in an osgi container, the vm transport will not work across bundles, because the broker registry is a static with bundle visibility. So failover:(tcp://...) is needed. But the communication is via a connection factory proxy from the osgi registry, so there should be only one version of the activemq classes that is shared. So it should work.

        Show
        gtully Gary Tully added a comment - - edited in an osgi container, the vm transport will not work across bundles, because the broker registry is a static with bundle visibility. So failover:(tcp://...) is needed. But the communication is via a connection factory proxy from the osgi registry, so there should be only one version of the activemq classes that is shared. So it should work.
        Hide
        gtully Gary Tully added a comment -

        the 'default' in the vm://default url needs to match the brokerName attribute of the broker, the default brokerName is localhost. When waitForStart is uses, it waits on the internal broker registry for an entry with that name.

        Show
        gtully Gary Tully added a comment - the 'default' in the vm://default url needs to match the brokerName attribute of the broker, the default brokerName is localhost. When waitForStart is uses, it waits on the internal broker registry for an entry with that name.
        Hide
        ffang Freeman Fang added a comment -

        @Jakub,

        Thanks for the patch, but I always get exception like
        22:43:45,442 | ERROR | rint Extender: 2 | BlueprintContainerImpl | 10 - org.apache.aries.blueprint - 0.3.1 | Unable to start blueprint container for bundle activemq-broker.xml
        org.osgi.service.blueprint.container.ComponentDefinitionException: Unresolved ref/idref to component: embeddedBroker
        at org.apache.aries.blueprint.container.BlueprintRepository.validate(BlueprintRepository.java:237)[10:org.apache.aries.blueprint:0.3.1]
        at org.apache.aries.blueprint.container.RecipeBuilder.createRepository(RecipeBuilder.java:92)[10:org.apache.aries.blueprint:0.3.1]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.getRepository(BlueprintContainerImpl.java:447)[10:org.apache.aries.blueprint:0.3.1]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:282)[10:org.apache.aries.blueprint:0.3.1]
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227)[10:org.apache.aries.blueprint:0.3.1]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)[:1.6.0_24]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)[:1.6.0_24]
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)[:1.6.0_24]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)[:1.6.0_24]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)[:1.6.0_24]
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_24]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_24]
        at java.lang.Thread.run(Thread.java:680)[:1.6.0_24]
        after apply your patch, I think the error comes from that the you add id="embededBroker" to <broker...>(broker is from activemq which have its own BeanDefinitionParser but seems it doesn't map broker id to bean id attribute), but not to <bean...>,

        @Gert,
        I like your approach more, and it indeed works when restart Servicemix, but it still have a problem if we simply refresh activemq-broker.xml bundle, as servicemix-wsn2005 need use jms broker, we can always see the error like
        ERROR: Bundle org.apache.servicemix.jbi.osgi [151] EventDispatcher: Error during dispatch. (org.apache.servicemix.nmr.api.ServiceMixException: Unable to register service servicemix-wsn2005 with properties

        {NAME=servicemix-wsn2005, objectClass=[Ljava.lang.String;@748996e8, service.id=440, TYPE=service-engine}. Reason: javax.jbi.JBIException: Error calling init)
        org.apache.servicemix.nmr.api.ServiceMixException: Unable to register service servicemix-wsn2005 with properties {NAME=servicemix-wsn2005, objectClass=[Ljava.lang.String;@748996e8, service.id=440, TYPE=service-engine}

        . Reason: javax.jbi.JBIException: Error calling init
        at org.apache.servicemix.nmr.core.ServiceRegistryImpl.register(ServiceRegistryImpl.java:52)
        at org.apache.servicemix.nmr.osgi.OsgiServiceRegistryTracker.addingService(OsgiServiceRegistryTracker.java:78)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840)
        at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859)
        at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721)
        at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649)
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781)
        at org.apache.felix.framework.Felix.access$000(Felix.java:79)
        at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723)
        at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107)
        at org.apache.felix.framework.Felix.registerService(Felix.java:2870)
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
        at org.apache.servicemix.jbi.deployer.impl.Deployer.registerService(Deployer.java:758)
        at org.apache.servicemix.jbi.deployer.impl.Deployer.registerComponent(Deployer.java:414)
        at org.apache.servicemix.jbi.deployer.impl.ComponentInstaller.initComponent(ComponentInstaller.java:424)
        at org.apache.servicemix.jbi.deployer.impl.ComponentInstaller.install(ComponentInstaller.java:150)
        at org.apache.servicemix.jbi.deployer.impl.Deployer.registerDeployedComponent(Deployer.java:653)
        at org.apache.servicemix.jbi.deployer.impl.Deployer$1.addingService(Deployer.java:218)
        at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896)
        at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
        at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
        at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840)
        at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859)
        at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721)
        at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649)
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781)
        at org.apache.felix.framework.Felix.access$000(Felix.java:79)
        at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723)
        at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107)
        at org.apache.felix.framework.Felix.registerService(Felix.java:2870)
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:404)
        at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:184)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.notifySatisfaction(BlueprintContainerImpl.java:612)
        at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.setSatisfied(AbstractServiceReferenceRecipe.java:305)
        at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceAdded(AbstractServiceReferenceRecipe.java:262)
        at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceChanged(AbstractServiceReferenceRecipe.java:245)
        at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859)
        at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721)
        at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649)
        at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781)
        at org.apache.felix.framework.Felix.access$000(Felix.java:79)
        at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723)
        at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107)
        at org.apache.felix.framework.Felix.registerService(Felix.java:2870)
        at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:404)
        at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:184)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerServices(BlueprintContainerImpl.java:662)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:330)
        at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:680)
        Caused by: javax.jbi.JBIException: Error calling init
        at org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:211)
        at org.apache.servicemix.jbi.deployer.artifacts.ComponentImpl$ComponentWrapper.init(ComponentImpl.java:247)
        at org.apache.servicemix.jbi.runtime.impl.ComponentRegistryImpl.doRegister(ComponentRegistryImpl.java:88)
        at org.apache.servicemix.jbi.runtime.impl.ComponentRegistryImpl.doRegister(ComponentRegistryImpl.java:37)
        at org.apache.servicemix.nmr.core.ServiceRegistryImpl.register(ServiceRegistryImpl.java:47)
        ... 61 more
        Caused by: javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Broker named 'default' does not exist.
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
        at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:249)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:262)
        at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:234)
        at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:182)
        at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:137)
        at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:121)
        at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:92)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50)
        at org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31)
        at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78)
        at $Proxy35.createConnection(Unknown Source)
        at org.apache.servicemix.wsn.jms.JmsNotificationBroker.init(JmsNotificationBroker.java:48)
        at org.apache.servicemix.wsn.component.WSNComponent.doInit(WSNComponent.java:165)
        at org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:205)
        ... 65 more
        Caused by: java.io.IOException: Broker named 'default' does not exist.
        at org.apache.activemq.transport.vm.VMTransportFactory.doCompositeConnect(VMTransportFactory.java:116)
        at org.apache.activemq.transport.vm.VMTransportFactory.doConnect(VMTransportFactory.java:54)
        at org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.java:51)
        at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:80)
        at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:247)
        ... 82 more
        no matter how long we set for the waitForStart in vm url (actually it just hang until waitForStart timeout then throw such exception and then the broker begin to start)

        Show
        ffang Freeman Fang added a comment - @Jakub, Thanks for the patch, but I always get exception like 22:43:45,442 | ERROR | rint Extender: 2 | BlueprintContainerImpl | 10 - org.apache.aries.blueprint - 0.3.1 | Unable to start blueprint container for bundle activemq-broker.xml org.osgi.service.blueprint.container.ComponentDefinitionException: Unresolved ref/idref to component: embeddedBroker at org.apache.aries.blueprint.container.BlueprintRepository.validate(BlueprintRepository.java:237) [10:org.apache.aries.blueprint:0.3.1] at org.apache.aries.blueprint.container.RecipeBuilder.createRepository(RecipeBuilder.java:92) [10:org.apache.aries.blueprint:0.3.1] at org.apache.aries.blueprint.container.BlueprintContainerImpl.getRepository(BlueprintContainerImpl.java:447) [10:org.apache.aries.blueprint:0.3.1] at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:282) [10:org.apache.aries.blueprint:0.3.1] at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227) [10:org.apache.aries.blueprint:0.3.1] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [:1.6.0_24] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [:1.6.0_24] at java.util.concurrent.FutureTask.run(FutureTask.java:138) [:1.6.0_24] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) [:1.6.0_24] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) [:1.6.0_24] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_24] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_24] at java.lang.Thread.run(Thread.java:680) [:1.6.0_24] after apply your patch, I think the error comes from that the you add id="embededBroker" to <broker...>(broker is from activemq which have its own BeanDefinitionParser but seems it doesn't map broker id to bean id attribute), but not to <bean...>, @Gert, I like your approach more, and it indeed works when restart Servicemix, but it still have a problem if we simply refresh activemq-broker.xml bundle, as servicemix-wsn2005 need use jms broker, we can always see the error like ERROR: Bundle org.apache.servicemix.jbi.osgi [151] EventDispatcher: Error during dispatch. (org.apache.servicemix.nmr.api.ServiceMixException: Unable to register service servicemix-wsn2005 with properties {NAME=servicemix-wsn2005, objectClass=[Ljava.lang.String;@748996e8, service.id=440, TYPE=service-engine}. Reason: javax.jbi.JBIException: Error calling init) org.apache.servicemix.nmr.api.ServiceMixException: Unable to register service servicemix-wsn2005 with properties {NAME=servicemix-wsn2005, objectClass=[Ljava.lang.String;@748996e8, service.id=440, TYPE=service-engine} . Reason: javax.jbi.JBIException: Error calling init at org.apache.servicemix.nmr.core.ServiceRegistryImpl.register(ServiceRegistryImpl.java:52) at org.apache.servicemix.nmr.osgi.OsgiServiceRegistryTracker.addingService(OsgiServiceRegistryTracker.java:78) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261) at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233) at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840) at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859) at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721) at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649) at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781) at org.apache.felix.framework.Felix.access$000(Felix.java:79) at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723) at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107) at org.apache.felix.framework.Felix.registerService(Felix.java:2870) at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251) at org.apache.servicemix.jbi.deployer.impl.Deployer.registerService(Deployer.java:758) at org.apache.servicemix.jbi.deployer.impl.Deployer.registerComponent(Deployer.java:414) at org.apache.servicemix.jbi.deployer.impl.ComponentInstaller.initComponent(ComponentInstaller.java:424) at org.apache.servicemix.jbi.deployer.impl.ComponentInstaller.install(ComponentInstaller.java:150) at org.apache.servicemix.jbi.deployer.impl.Deployer.registerDeployedComponent(Deployer.java:653) at org.apache.servicemix.jbi.deployer.impl.Deployer$1.addingService(Deployer.java:218) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261) at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233) at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840) at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859) at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721) at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649) at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781) at org.apache.felix.framework.Felix.access$000(Felix.java:79) at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723) at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107) at org.apache.felix.framework.Felix.registerService(Felix.java:2870) at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251) at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:404) at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:184) at org.apache.aries.blueprint.container.BlueprintContainerImpl.notifySatisfaction(BlueprintContainerImpl.java:612) at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.setSatisfied(AbstractServiceReferenceRecipe.java:305) at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceAdded(AbstractServiceReferenceRecipe.java:262) at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.serviceChanged(AbstractServiceReferenceRecipe.java:245) at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:859) at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:721) at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:649) at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3781) at org.apache.felix.framework.Felix.access$000(Felix.java:79) at org.apache.felix.framework.Felix$2.serviceChanged(Felix.java:723) at org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.java:107) at org.apache.felix.framework.Felix.registerService(Felix.java:2870) at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251) at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerService(BlueprintContainerImpl.java:404) at org.apache.aries.blueprint.container.ServiceRecipe.register(ServiceRecipe.java:184) at org.apache.aries.blueprint.container.BlueprintContainerImpl.registerServices(BlueprintContainerImpl.java:662) at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:330) at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:227) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) Caused by: javax.jbi.JBIException: Error calling init at org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:211) at org.apache.servicemix.jbi.deployer.artifacts.ComponentImpl$ComponentWrapper.init(ComponentImpl.java:247) at org.apache.servicemix.jbi.runtime.impl.ComponentRegistryImpl.doRegister(ComponentRegistryImpl.java:88) at org.apache.servicemix.jbi.runtime.impl.ComponentRegistryImpl.doRegister(ComponentRegistryImpl.java:37) at org.apache.servicemix.nmr.core.ServiceRegistryImpl.register(ServiceRegistryImpl.java:47) ... 61 more Caused by: javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Broker named 'default' does not exist. at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35) at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:249) at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:262) at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:234) at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:182) at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:137) at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:121) at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:92) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.aries.proxy.impl.ProxyHandler$1.invoke(ProxyHandler.java:50) at org.apache.aries.proxy.impl.DefaultWrapper.invoke(DefaultWrapper.java:31) at org.apache.aries.proxy.impl.ProxyHandler.invoke(ProxyHandler.java:78) at $Proxy35.createConnection(Unknown Source) at org.apache.servicemix.wsn.jms.JmsNotificationBroker.init(JmsNotificationBroker.java:48) at org.apache.servicemix.wsn.component.WSNComponent.doInit(WSNComponent.java:165) at org.apache.servicemix.common.AsyncBaseLifeCycle.init(AsyncBaseLifeCycle.java:205) ... 65 more Caused by: java.io.IOException: Broker named 'default' does not exist. at org.apache.activemq.transport.vm.VMTransportFactory.doCompositeConnect(VMTransportFactory.java:116) at org.apache.activemq.transport.vm.VMTransportFactory.doConnect(VMTransportFactory.java:54) at org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.java:51) at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:80) at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:247) ... 82 more no matter how long we set for the waitForStart in vm url (actually it just hang until waitForStart timeout then throw such exception and then the broker begin to start)
        Hide
        gertvanthienen Gert Vanthienen added a comment -

        Another option could be to use vm://default?create=false (perhaps with the waitForStart option) - that would also wait for the broker to start but would also allow us to leverage the faster vm: transport instead of going over TCP/IP when communicating with the embedded broker.

        Show
        gertvanthienen Gert Vanthienen added a comment - Another option could be to use vm://default?create=false (perhaps with the waitForStart option) - that would also wait for the broker to start but would also allow us to leverage the faster vm: transport instead of going over TCP/IP when communicating with the embedded broker.
        Hide
        jkorab Jakub Korab added a comment -

        Attached is a version of activemq-broker.xml that contains this change.

        Show
        jkorab Jakub Korab added a comment - Attached is a version of activemq-broker.xml that contains this change.

          People

          • Assignee:
            ffang Freeman Fang
            Reporter:
            jkorab Jakub Korab
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development