0 Replies Latest reply on May 21, 2013 11:26 AM by David S. Arnold

    mq-fabric BundleContext is null when using discovery agent

    David S. Arnold Newbie

      I'm trying to use a discovery:(fabric:primary) URI to create an activemq connection pool on JBoss FUSE 7.1.0 and receiving a NullPointerException.  The pool is being created on a child container with an ESB profile.  The "primary" broker group is a master/slave pair residing in their own separate child containers (one on the same server as the ESB container, one remote).

       

      Having looked at the code for the ServiceTracker in the relevant felix framework version, I can see that it's the FabricDiscoverAgent passing a null BundleContext to the ServiceTracker during its construction:

       

          public FabricDiscoveryAgent() {

              if (FrameworkUtil.getBundle(getClass()) != null) {

                  context = FrameworkUtil.getBundle(getClass()).getBundleContext();

                  tracker = new ServiceTracker(context, IZKClient.class.getName(), this);

                  ...

       

      I just can't figure out how a started bundle can have a null BundleContext. 

       

      Here's the blueprint:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"

                xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"

                xmlns:camel="http://camel.apache.org/schema/blueprint" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"

                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd

                                                                  http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd

                                                                  http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd

                                                               http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

       

       

                <cm:property-placeholder persistent-id="ca.mcmaster.uts.service.peoplesoft">

          <cm:default-properties>

            <cm:property name="broker.user" value="**" />

            <cm:property name="broker.password" value="**" />

            <cm:property name="broker.compression" value="false" />

            <cm:property name="broker.socketBufferSize" value="131072" />

          </cm:default-properties>

                </cm:property-placeholder>

       

       

                <camel:camelContext id="camelContext" depends-on="activemq,errorHandler">

                            <camel:route>

            <camel:from uri="cxf:bean:peopleSoftServiceEndpoint?portName={http://mcmaster.ca/service/peoplesoft}PeopleSoftServiceSOAP12Port" />

            <camel:to uri="activemq:peoplesoft" />

          </camel:route>

       

          <camel:route errorHandlerRef="errorHandler">

            <camel:from uri="activemq:peoplesoft" />

            <camel:transacted ref="PROPAGATION_REQUIRES_NEW" />

            <camel:to uri="log:ca.mcmaster.uts.service.peoplesoft?level=INFO" />

          </camel:route>

                </camel:camelContext>

       

       

                <bean id="PROPAGATION_REQUIRES_NEW" class="org.apache.camel.spring.spi.SpringTransactionPolicy">

          <property name="transactionManager" ref="jmsTransactionManager" />

          <property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW" />

                </bean>

       

       

                <bean id="errorHandler" class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">

          <property name="transactionManager" ref="jmsTransactionManager" />

          <property name="deadLetterUri" value="activemq:deadLogs" />

          <property name="redeliveryPolicy" ref="loggingRedeliveryPolicyConfig" />

                </bean>

       

       

                <bean id="loggingRedeliveryPolicyConfig" class="org.apache.camel.processor.RedeliveryPolicy">

          <property name="maximumRedeliveries" value="10" />

          <property name="redeliveryDelay" value="500" />

          <property name="backOffMultiplier" value="2" />

                </bean>

       

       

                <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">

          <property name="connectionFactory" ref="jmsConnectionFactory" />

                </bean>

       

       

                <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">

          <property name="brokerURL" value="discovery://(fabric://primary)" />

          <property name="userName" value="${broker.user}" />

          <property name="password" value="${broker.password}" />

          <property name="useCompression" value="${broker.compression}" />

                </bean>

       

       

                <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">

          <property name="maxConnections" value="10" />

          <property name="connectionFactory" ref="jmsConnectionFactory" />

                </bean>

       

       

                <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">

          <property name="connectionFactory" ref="pooledConnectionFactory" />

          <property name="concurrentConsumers" value="10" />

          <property name="transacted" value="true" />

          <property name="transactionManager" ref="jmsTransactionManager" />

                </bean>

       

       

                <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">

          <property name="configuration" ref="jmsConfig" />

                </bean>

      </blueprint>

       

      Here's the full stack trace:

       

       

      2013-05-14 16:37:31,747 | INFO  | agent-1-thread-1 | DeploymentAgent                  | rce.fabric.agent.DeploymentAgent  743 | 67 - org.fusesource.fabric.fabric-agent - 7.1.0.fuse-047 | Starting bundles:

      2013-05-14 16:37:31,748 | INFO  | agent-1-thread-1 | DeploymentAgent                  | rce.fabric.agent.DeploymentAgent  748 | 67 - org.fusesource.fabric.fabric-agent - 7.1.0.fuse-047 |   org.fusesource.mq.mq-fabric / 7.1.0.fuse-047

      2013-05-14 16:37:31,837 | INFO  | agent-1-thread-1 | DeploymentAgent                  | rce.fabric.agent.DeploymentAgent  748 | 67 - org.fusesource.fabric.fabric-agent - 7.1.0.fuse-047 |   ca.mcmaster.uts.peoplesoft-service / 1.0.7

      2013-05-14 16:37:31,974 | INFO  | e-1.0.7-thread-1 | ManagementStrategyFactory        | gement.ManagementStrategyFactory   43 | 81 - org.apache.camel.camel-core - 2.10.0.fuse-71-047 | JMX enabled.

      2013-05-14 16:37:32,005 | WARN  | e-1.0.7-thread-1 | PooledConnectionFactory          | emq.pool.PooledConnectionFactory  262 | 134 - org.apache.activemq.activemq-pool - 5.7.0.fuse-71-047 | Create pooled connection during start failed. This exception will be ignored.

      javax.jms.JMSException: Error while attempting to add new Connection to the pool

              at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)

              at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:216)[134:org.apache.activemq.activemq-pool:5.7.0.fuse-71-047]

              at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:195)[134:org.apache.activemq.activemq-pool:5.7.0.fuse-71-047]

              at org.apache.activemq.pool.PooledConnectionFactory.start(PooledConnectionFactory.java:260)[134:org.apache.activemq.activemq-pool:5.7.0.fuse-71-047]

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_09-icedtea]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_09-icedtea]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_09-icedtea]

              at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_09-icedtea]

              at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:297)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:958)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:712)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:824)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_09-icedtea]

              at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_09-icedtea]

              at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:649)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:356)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:255)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BlueprintExtender.checkBundle(BlueprintExtender.java:325)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BlueprintExtender.bundleChanged(BlueprintExtender.java:243)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.blueprint.container.BlueprintExtender$BlueprintBundleTrackerCustomizer.modifiedBundle(BlueprintExtender.java:471)[7:org.apache.aries.blueprint.core:1.0.1.fuse-71-047]

              at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:198)[9:org.apache.aries.util:1.0.0]

              at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:128)[9:org.apache.aries.util:1.0.0]

              at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:468)[9:org.apache.aries.util:1.0.0]

              at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:161)[9:org.apache.aries.util:1.0.0]

              at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:117)[9:org.apache.aries.util:1.0.0]

              at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.0.3.fuse-71-047.jar:]

              at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)[org.apache.felix.framework-4.0.3.fuse-71-047.jar:]

              at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)[org.apache.felix.framework-4.0.3.fuse-71-047.jar:]

              at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4479)[org.apache.felix.framework-4.0.3.fuse-71-047.jar:]

              at org.apache.felix.framework.Felix$4.run(Felix.java:2019)[org.apache.felix.framework-4.0.3.fuse-71-047.jar:]

              at org.apache.felix.framework.Felix$5.run(Felix.java:2061)[org.apache.felix.framework-4.0.3.fuse-71-047.jar:]

              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_09-icedtea]

              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_09-icedtea]

              at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_09-icedtea]

              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_09-icedtea]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_09-icedtea]

              at java.lang.Thread.run(Thread.java:722)[:1.7.0_09-icedtea]

      Caused by: javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Could not create discovery agent: fabric:primary

              at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)

              at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:252)[197:org.apache.activemq.activemq-core:5.7.0.fuse-71-047]

              at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:265)[197:org.apache.activemq.activemq-core:5.7.0.fuse-71-047]

              at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:238)[197:org.apache.activemq.activemq-core:5.7.0.fuse-71-047]

              at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:184)[197:org.apache.activemq.activemq-core:5.7.0.fuse-71-047]

              at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:247)[134:org.apache.activemq.activemq-pool:5.7.0.fuse-71-047]

              at org.apache.activemq.pool.PooledConnectionFactory$1.makeObject(PooledConnectionFactory.java:131)[134:org.apache.activemq.activemq-pool:5.7.0.fuse-71-047]

              at org.apache.activemq.pool.PooledConnectionFactory$1.makeObject(PooledConnectionFactory.java:111)[134:org.apache.activemq.activemq-pool:5.7.0.fuse-71-047]

              at org.apache.commons.pool.impl.GenericKeyedObjectPool.addObject(GenericKeyedObjectPool.java:1748)

              at org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:214)[134:org.apache.activemq.activemq-pool:5.7.0.fuse-71-047]

              ... 40 more

      Caused by: java.io.IOException: Could not create discovery agent: fabric:primary

              at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)

              at org.fusesource.mq.fabric.FabricDiscoveryAgentFactory.doCreateDiscoveryAgent(FabricDiscoveryAgentFactory.java:47)

              at org.apache.activemq.transport.discovery.DiscoveryAgentFactory.createDiscoveryAgent(DiscoveryAgentFactory.java:56)

              at org.apache.activemq.transport.discovery.DiscoveryTransportFactory.createTransport(DiscoveryTransportFactory.java:58)

              at org.apache.activemq.transport.discovery.DiscoveryTransportFactory.createTransport(DiscoveryTransportFactory.java:40)

              at org.apache.activemq.transport.failover.FailoverTransportFactory.doConnect(FailoverTransportFactory.java:37)

              at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:67)

              at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:250)[197:org.apache.activemq.activemq-core:5.7.0.fuse-71-047]

              ... 48 more

      Caused by: java.lang.NullPointerException

              at org.osgi.util.tracker.ServiceTracker.<init>(ServiceTracker.java:184)[karaf.jar:2.3.0.fuse-71-047]

              at org.fusesource.mq.fabric.FabricDiscoveryAgent.<init>(FabricDiscoveryAgent.java:124)

              at org.fusesource.mq.fabric.FabricDiscoveryAgentFactory.doCreateDiscoveryAgent(FabricDiscoveryAgentFactory.java:34)