You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by niels <st...@gmail.com> on 2015/03/24 14:59:21 UTC

Retrieve reference of JMS ConnectionFactory

Hey,

I'm trying to get a reference to the ActiveMQ connection factory service
I've exported. 
But without any luck, I was hoping somebody could help me and point me in
the right direction.

This is the blueprint file I have to setup ActiveMQ and export the service:

/<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           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">

    <bean id="activemqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL"
value="vm://amq-broker?create=false&amp;waitForStart=10000" />
    </bean>

    <bean id="pooledConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
        <property name="maxConnections" value="8" />
        <property name="connectionFactory" ref="activemqConnectionFactory"
/>
    </bean>

    <bean id="resourceManager"
class="org.apache.activemq.pool.ActiveMQResourceManager"
init-method="recoverResource">
        <property name="transactionManager" ref="recoverableTxManager" />
        <property name="connectionFactory" ref="activemqConnectionFactory"
/>
        <property name="resourceName" value="activemq.amq-broker" />
    </bean>

    <reference id="recoverableTxManager"
interface="org.apache.geronimo.transaction.manager.RecoverableTransactionManager"
availability="mandatory" />

    <service ref="pooledConnectionFactory"
interface="javax.jms.ConnectionFactory">
        <service-properties>
            <entry key="name" value="localhost"/>
        </service-properties>
    </service>
</blueprint>/

But when I check the headers from this package I noticed there isn't any
`Export-Service` listed for that bundle.

And when I try to get a reference in another blueprint file like this:

/<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           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">

      ....
    <reference id="jmsConnectionFactory"
interface="javax.jms.ConnectionFactory"/>

    <bean id="invoiceEventPublisher"
class="nl.kabisa.flux.invoicing.InvoiceEventPublisher">
        <property name="connectionFactory" ref="jmsConnectionFactory"/>
    </bean>

    ....
</blueprint>/

I get the following log message:

/ 2015-03-24 14:33:00,831 | ERROR | -SNAPSHOT/deploy |
BlueprintContainerImpl           | ?                                   ? | 7
- org.apache.aries.blueprint.core - 1.4.0 | Unable to start blueprint
container for bundle ID_550952684d61638714670000.xml
org.osgi.service.blueprint.container.ComponentDefinitionException:
java.lang.NullPointerException
	at
org.apache.aries.blueprint.container.ReferenceRecipe.internalCreate(ReferenceRecipe.java:122)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[7:org.apache.aries.blueprint.core:1.4.0]
	at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_11]
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_11]
	at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:681)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:378)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[10:org.apache.aries.util:1.1.0]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[10:org.apache.aries.util:1.1.0]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[10:org.apache.aries.util:1.1.0]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[10:org.apache.aries.util:1.1.0]
	at
org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[10:org.apache.aries.util:1.1.0]
	at
org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.0.3.jar:]
	at
org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)[org.apache.felix.framework-4.0.3.jar:]
	at
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)[org.apache.felix.framework-4.0.3.jar:]
	at
org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4244)[org.apache.felix.framework-4.0.3.jar:]
	at
org.apache.felix.framework.Felix.startBundle(Felix.java:1923)[org.apache.felix.framework-4.0.3.jar:]
	at
org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)[org.apache.felix.framework-4.0.3.jar:]
	at
org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[6:org.apache.felix.fileinstall:3.4.0]
	at
org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[6:org.apache.felix.fileinstall:3.4.0]
	at
org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1207)[6:org.apache.felix.fileinstall:3.4.0]
	at
org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:504)[6:org.apache.felix.fileinstall:3.4.0]
	at
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[6:org.apache.felix.fileinstall:3.4.0]
	at
org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[6:org.apache.felix.fileinstall:3.4.0]
Caused by: java.lang.NullPointerException
	at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1432)[org.apache.felix.framework-4.0.3.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
	at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:410)[:1.7.0_11]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_11]
	at java.lang.Class.forName0(Native Method)[:1.7.0_11]
	at java.lang.Class.forName(Class.java:264)[:1.7.0_11]
	at
org.apache.aries.proxy.impl.interfaces.ProxyClassLoader.isInvalid(ProxyClassLoader.java:109)[12:org.apache.aries.proxy.impl:1.0.2]
	at
org.apache.aries.proxy.impl.interfaces.InterfaceProxyGenerator.getProxyInstance(InterfaceProxyGenerator.java:84)[12:org.apache.aries.proxy.impl:1.0.2]
	at
org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:72)[12:org.apache.aries.proxy.impl:1.0.2]
	at
org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingInterceptingProxy(AbstractProxyManager.java:75)[12:org.apache.aries.proxy.impl:1.0.2]
	at
org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingProxy(AbstractProxyManager.java:40)[12:org.apache.aries.proxy.impl:1.0.2]
	at
org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.createProxy(AbstractServiceReferenceRecipe.java:338)[7:org.apache.aries.blueprint.core:1.4.0]
	at
org.apache.aries.blueprint.container.ReferenceRecipe.internalCreate(ReferenceRecipe.java:106)[7:org.apache.aries.blueprint.core:1.4.0]/

So apparently no service is found for the specific interface. I find this
strange since I have several bundles running with Camel and also using the
ActiveMQ queues in between. Those bundles don't complain of a
ConnectionFactory missing. 
I'm assuming I'm missing something to export the service. Is there anybody
who could point me in the right direction? All help is welcome.

Cheers,

Niels






--
View this message in context: http://karaf.922171.n3.nabble.com/Retrieve-reference-of-JMS-ConnectionFactory-tp4039259.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Retrieve reference of JMS ConnectionFactory

Posted by Sobkowiak Krzysztof <kr...@gmail.com>.
Hi

I think, you do everything correct. You can test the connection factory successful. The way you reference the connection factory is correct too. You can have the problem
reported  for ARIES. I have tested simillar problem for ServiceMix yesterday and I have found this problem occurs only in Karaf 2.3.x. It would clarify why do you have this
problem using Karaf 2.3.6. In Karaf 2.4.x and 3.0.x it seems to be fixed. Probably it has been fixed in the newer version for Felix or Arieused in 2.4+.

This problem usually occurs while  updating the bundle. You write you have the problem while deploying (also no update should occur). I can remember, one of the Karaf
releases  from the line 2.3.x had a problem with hot deployment - it looked like the bundle was refreshed while deploying. Could you please test it on the newer versions of
2.3.x (e.g. 2.3.10)?

Regards
Krzysztof

On 25.03.2015 09:11, niels wrote:
> Hey Krzysztof,
>
> I forgot to mention versions:
> - Karaf 2.3.6
> - ActiveMQ 5.9.0
> - Camel 2.13.2
>
> I also installed the JMS bundle and was able to list the connection factory:
>
> karaf@flux>jms:connectionfactories
> JMS Connection Factory
> localhost
>
> I'm also able to list the queues from AMQ without ClassNotFoundException you
> first received.
>
> karaf@flux>jms:queues localhost
> JMS Queues
> ID_550952684d61638714670000_f934b9e9-fd31-470b-a924-1a7c306f6b22
> tracing
> elasticsearch_log
> ID_550952684d61638714670000_9701e4b3-37ef-4934-8882-deddb2d033fa
> invoicing
>
> The only thing I try to do in the second bundle is to capture a reference to
> the exported ConnectionFactory like I mentioned earlier:
>
>     <reference id="jmsConnectionFactory"
> interface="javax.jms.ConnectionFactory"/>
>
> The blueprint file are deployed by the dropping them in de deploy directory
> for hot deploys. 
>
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Retrieve-reference-of-JMS-ConnectionFactory-tp4039259p4039286.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

-- 
Krzysztof Sobkowiak

JEE & OSS Architect
Senior Solution Architect @ Capgemini SSC <http://www.pl.capgemini-sdm.com/en/>
Apache ServiceMix <http://servicemix.apache.org/> Committer & PMC

Re: Retrieve reference of JMS ConnectionFactory

Posted by niels <st...@gmail.com>.
Hey Krzysztof,

I forgot to mention versions:
- Karaf 2.3.6
- ActiveMQ 5.9.0
- Camel 2.13.2

I also installed the JMS bundle and was able to list the connection factory:

karaf@flux>jms:connectionfactories
JMS Connection Factory
localhost

I'm also able to list the queues from AMQ without ClassNotFoundException you
first received.

karaf@flux>jms:queues localhost
JMS Queues
ID_550952684d61638714670000_f934b9e9-fd31-470b-a924-1a7c306f6b22
tracing
elasticsearch_log
ID_550952684d61638714670000_9701e4b3-37ef-4934-8882-deddb2d033fa
invoicing

The only thing I try to do in the second bundle is to capture a reference to
the exported ConnectionFactory like I mentioned earlier:

    <reference id="jmsConnectionFactory"
interface="javax.jms.ConnectionFactory"/>

The blueprint file are deployed by the dropping them in de deploy directory
for hot deploys. 






--
View this message in context: http://karaf.922171.n3.nabble.com/Retrieve-reference-of-JMS-ConnectionFactory-tp4039259p4039286.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Retrieve reference of JMS ConnectionFactory

Posted by Krzysztof Sobkowiak <kr...@gmail.com>.
Hi

I have performed some test on karaf 2.4.1 with Camel 2.14.2 and ActiveMQ 5.10.2

karaf@root> features:chooseurl activemq 5.10.2
karaf@root> features:chooseurl camel 2.14.2
karaf@root> features:install activemq-broker activemq-blueprint activemq-camel
karaf@root> features:install camel-blueprint camel-jms

I have also installed the jmsfeature for tests

karaf@root> features:install jms

Next I have deployed your connection factory (your first blueprint) into the deploy directory. No problem. I have done
only one modification by adding a osgi.jndi.service.name property to the exported service to allow to manage it by the
jms commands

   <service ref="pooledConnectionFactory" interface="javax.jms.ConnectionFactory">
        <service-properties>
         <entry key="osgi.jndi.service.name" value="jms/localhost" />
            <entry key="name" value="localhost"/>
        </service-properties>
    </service> 

Next:

karaf@root> list
.....
[ 143] [Active     ] [Created     ] [       ] [   80] cf.xml (0.0.0)


karaf@root> ls 143

Bundle 143 provides:
--------------------
name = localhost
objectClass = [javax.jms.ConnectionFactory]
osgi.jndi.service.name = jms/localhost
osgi.service.blueprint.compname = pooledConnectionFactory
service.id = 480
----
objectClass = [org.osgi.service.blueprint.container.BlueprintContainer]
osgi.blueprint.container.symbolicname = cf.xml
osgi.blueprint.container.version = 0.0.0
service.id = 481


The connection factory seems to be correctly exported as OSGi service. Yet some tests:


karaf@root> jms:queues jms/localhost
JMS Queues
Error executing command: org/apache/activemq/pool/PooledConnection

I had one error while sending message into the queue

java.lang.ClassNotFoundException: org.apache.activemq.pool.PooledConnection not found by org.apache.karaf.jms.core [55]

Refreshing the bundle org.apache.karaf.jms.core helped.

karaf@root> jms:connectionfactories
JMS Connection Factory
jms/localhost
karaf@root> jms:send jms/localhost test-queue "test message"
karaf@root> jms:queues jms/localhost
JMS Queues
test-queue

Please check first your Connection Factory like above to be sure it has been correctly exported.

Similar problems have been already reported:

  *

    https://issues.apache.org/jira/browse/ARIES-959

  *

    https://issues.apache.org/jira/browse/ARIES-961

  *

    https://issues.apache.org/jira/browse/ARIES-1151

  *

    https://issues.apache.org/jira/browse/SM-2338

I suppose the problem is somewhere in your second bundle and is caused by an issue in Aries or Felix. In this post a
user reports the problem and using Equinox instead of Felix seems to solve this problem
(http://karaf.922171.n3.nabble.com/Error-when-updating-a-bundle-td4031720.html)

Regards
Krzysztof


On 24.03.2015 17:43, Krzysztof Sobkowiak wrote:
> Hi
>
> Could you tell a bit more how are you deploying this connection factory configuration (bundle containing this blueprint
> or blueprint in deploy directory)? Which versions (Karaf, Camel, ActiveMQ) are you using?
>
> Regards
> Krzysztof
>
>
> On 24.03.2015 14:59, niels wrote:
>> Hey,
>>
>> I'm trying to get a reference to the ActiveMQ connection factory service
>> I've exported. 
>> But without any luck, I was hoping somebody could help me and point me in
>> the right direction.
>>
>> This is the blueprint file I have to setup ActiveMQ and export the service:
>>
>> /<?xml version="1.0" encoding="UTF-8"?>
>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>            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">
>>
>>     <bean id="activemqConnectionFactory"
>> class="org.apache.activemq.ActiveMQConnectionFactory">
>>         <property name="brokerURL"
>> value="vm://amq-broker?create=false&amp;waitForStart=10000" />
>>     </bean>
>>
>>     <bean id="pooledConnectionFactory"
>> class="org.apache.activemq.pool.PooledConnectionFactory">
>>         <property name="maxConnections" value="8" />
>>         <property name="connectionFactory" ref="activemqConnectionFactory"
>> />
>>     </bean>
>>
>>     <bean id="resourceManager"
>> class="org.apache.activemq.pool.ActiveMQResourceManager"
>> init-method="recoverResource">
>>         <property name="transactionManager" ref="recoverableTxManager" />
>>         <property name="connectionFactory" ref="activemqConnectionFactory"
>> />
>>         <property name="resourceName" value="activemq.amq-broker" />
>>     </bean>
>>
>>     <reference id="recoverableTxManager"
>> interface="org.apache.geronimo.transaction.manager.RecoverableTransactionManager"
>> availability="mandatory" />
>>
>>     <service ref="pooledConnectionFactory"
>> interface="javax.jms.ConnectionFactory">
>>         <service-properties>
>>             <entry key="name" value="localhost"/>
>>         </service-properties>
>>     </service>
>> </blueprint>/
>>
>> But when I check the headers from this package I noticed there isn't any
>> `Export-Service` listed for that bundle.
>>
>> And when I try to get a reference in another blueprint file like this:
>>
>> /<?xml version="1.0" encoding="UTF-8"?>
>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>            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">
>>
>>       ....
>>     <reference id="jmsConnectionFactory"
>> interface="javax.jms.ConnectionFactory"/>
>>
>>     <bean id="invoiceEventPublisher"
>> class="nl.kabisa.flux.invoicing.InvoiceEventPublisher">
>>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>>     </bean>
>>
>>     ....
>> </blueprint>/
>>
>> I get the following log message:
>>
>> / 2015-03-24 14:33:00,831 | ERROR | -SNAPSHOT/deploy |
>> BlueprintContainerImpl           | ?                                   ? | 7
>> - org.apache.aries.blueprint.core - 1.4.0 | Unable to start blueprint
>> container for bundle ID_550952684d61638714670000.xml
>> org.osgi.service.blueprint.container.ComponentDefinitionException:
>> java.lang.NullPointerException
>> 	at
>> org.apache.aries.blueprint.container.ReferenceRecipe.internalCreate(ReferenceRecipe.java:122)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_11]
>> 	at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_11]
>> 	at
>> org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:681)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:378)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[10:org.apache.aries.util:1.1.0]
>> 	at
>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[10:org.apache.aries.util:1.1.0]
>> 	at
>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[10:org.apache.aries.util:1.1.0]
>> 	at
>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[10:org.apache.aries.util:1.1.0]
>> 	at
>> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[10:org.apache.aries.util:1.1.0]
>> 	at
>> org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.0.3.jar:]
>> 	at
>> org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)[org.apache.felix.framework-4.0.3.jar:]
>> 	at
>> org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)[org.apache.felix.framework-4.0.3.jar:]
>> 	at
>> org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4244)[org.apache.felix.framework-4.0.3.jar:]
>> 	at
>> org.apache.felix.framework.Felix.startBundle(Felix.java:1923)[org.apache.felix.framework-4.0.3.jar:]
>> 	at
>> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)[org.apache.felix.framework-4.0.3.jar:]
>> 	at
>> org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[6:org.apache.felix.fileinstall:3.4.0]
>> 	at
>> org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[6:org.apache.felix.fileinstall:3.4.0]
>> 	at
>> org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1207)[6:org.apache.felix.fileinstall:3.4.0]
>> 	at
>> org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:504)[6:org.apache.felix.fileinstall:3.4.0]
>> 	at
>> org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[6:org.apache.felix.fileinstall:3.4.0]
>> 	at
>> org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[6:org.apache.felix.fileinstall:3.4.0]
>> Caused by: java.lang.NullPointerException
>> 	at
>> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1432)[org.apache.felix.framework-4.0.3.jar:]
>> 	at
>> org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
>> 	at
>> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
>> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:410)[:1.7.0_11]
>> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_11]
>> 	at java.lang.Class.forName0(Native Method)[:1.7.0_11]
>> 	at java.lang.Class.forName(Class.java:264)[:1.7.0_11]
>> 	at
>> org.apache.aries.proxy.impl.interfaces.ProxyClassLoader.isInvalid(ProxyClassLoader.java:109)[12:org.apache.aries.proxy.impl:1.0.2]
>> 	at
>> org.apache.aries.proxy.impl.interfaces.InterfaceProxyGenerator.getProxyInstance(InterfaceProxyGenerator.java:84)[12:org.apache.aries.proxy.impl:1.0.2]
>> 	at
>> org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:72)[12:org.apache.aries.proxy.impl:1.0.2]
>> 	at
>> org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingInterceptingProxy(AbstractProxyManager.java:75)[12:org.apache.aries.proxy.impl:1.0.2]
>> 	at
>> org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingProxy(AbstractProxyManager.java:40)[12:org.apache.aries.proxy.impl:1.0.2]
>> 	at
>> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.createProxy(AbstractServiceReferenceRecipe.java:338)[7:org.apache.aries.blueprint.core:1.4.0]
>> 	at
>> org.apache.aries.blueprint.container.ReferenceRecipe.internalCreate(ReferenceRecipe.java:106)[7:org.apache.aries.blueprint.core:1.4.0]/
>>
>> So apparently no service is found for the specific interface. I find this
>> strange since I have several bundles running with Camel and also using the
>> ActiveMQ queues in between. Those bundles don't complain of a
>> ConnectionFactory missing. 
>> I'm assuming I'm missing something to export the service. Is there anybody
>> who could point me in the right direction? All help is welcome.
>>
>> Cheers,
>>
>> Niels
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://karaf.922171.n3.nabble.com/Retrieve-reference-of-JMS-ConnectionFactory-tp4039259.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.

-- 
Krzysztof Sobkowiak

JEE & OSS Architect
Senior Solution Architect @ Capgemini SSC <http://www.pl.capgemini-sdm.com/en>
Apache ServiceMix <http://servicemix.apache.org/> Committer & PMC

Re: Retrieve reference of JMS ConnectionFactory

Posted by Krzysztof Sobkowiak <kr...@gmail.com>.
Hi

Could you tell a bit more how are you deploying this connection factory configuration (bundle containing this blueprint
or blueprint in deploy directory)? Which versions (Karaf, Camel, ActiveMQ) are you using?

Regards
Krzysztof


On 24.03.2015 14:59, niels wrote:
> Hey,
>
> I'm trying to get a reference to the ActiveMQ connection factory service
> I've exported. 
> But without any luck, I was hoping somebody could help me and point me in
> the right direction.
>
> This is the blueprint file I have to setup ActiveMQ and export the service:
>
> /<?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>            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">
>
>     <bean id="activemqConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>         <property name="brokerURL"
> value="vm://amq-broker?create=false&amp;waitForStart=10000" />
>     </bean>
>
>     <bean id="pooledConnectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>         <property name="maxConnections" value="8" />
>         <property name="connectionFactory" ref="activemqConnectionFactory"
> />
>     </bean>
>
>     <bean id="resourceManager"
> class="org.apache.activemq.pool.ActiveMQResourceManager"
> init-method="recoverResource">
>         <property name="transactionManager" ref="recoverableTxManager" />
>         <property name="connectionFactory" ref="activemqConnectionFactory"
> />
>         <property name="resourceName" value="activemq.amq-broker" />
>     </bean>
>
>     <reference id="recoverableTxManager"
> interface="org.apache.geronimo.transaction.manager.RecoverableTransactionManager"
> availability="mandatory" />
>
>     <service ref="pooledConnectionFactory"
> interface="javax.jms.ConnectionFactory">
>         <service-properties>
>             <entry key="name" value="localhost"/>
>         </service-properties>
>     </service>
> </blueprint>/
>
> But when I check the headers from this package I noticed there isn't any
> `Export-Service` listed for that bundle.
>
> And when I try to get a reference in another blueprint file like this:
>
> /<?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>            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">
>
>       ....
>     <reference id="jmsConnectionFactory"
> interface="javax.jms.ConnectionFactory"/>
>
>     <bean id="invoiceEventPublisher"
> class="nl.kabisa.flux.invoicing.InvoiceEventPublisher">
>         <property name="connectionFactory" ref="jmsConnectionFactory"/>
>     </bean>
>
>     ....
> </blueprint>/
>
> I get the following log message:
>
> / 2015-03-24 14:33:00,831 | ERROR | -SNAPSHOT/deploy |
> BlueprintContainerImpl           | ?                                   ? | 7
> - org.apache.aries.blueprint.core - 1.4.0 | Unable to start blueprint
> container for bundle ID_550952684d61638714670000.xml
> org.osgi.service.blueprint.container.ComponentDefinitionException:
> java.lang.NullPointerException
> 	at
> org.apache.aries.blueprint.container.ReferenceRecipe.internalCreate(ReferenceRecipe.java:122)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0_11]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_11]
> 	at
> org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:245)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:681)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:378)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:269)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:245)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:235)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[10:org.apache.aries.util:1.1.0]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[10:org.apache.aries.util:1.1.0]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[10:org.apache.aries.util:1.1.0]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[10:org.apache.aries.util:1.1.0]
> 	at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[10:org.apache.aries.util:1.1.0]
> 	at
> org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1103)[org.apache.felix.framework-4.0.3.jar:]
> 	at
> org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:695)[org.apache.felix.framework-4.0.3.jar:]
> 	at
> org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:483)[org.apache.felix.framework-4.0.3.jar:]
> 	at
> org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4244)[org.apache.felix.framework-4.0.3.jar:]
> 	at
> org.apache.felix.framework.Felix.startBundle(Felix.java:1923)[org.apache.felix.framework-4.0.3.jar:]
> 	at
> org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)[org.apache.felix.framework-4.0.3.jar:]
> 	at
> org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1245)[6:org.apache.felix.fileinstall:3.4.0]
> 	at
> org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1217)[6:org.apache.felix.fileinstall:3.4.0]
> 	at
> org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1207)[6:org.apache.felix.fileinstall:3.4.0]
> 	at
> org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:504)[6:org.apache.felix.fileinstall:3.4.0]
> 	at
> org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:358)[6:org.apache.felix.fileinstall:3.4.0]
> 	at
> org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:310)[6:org.apache.felix.fileinstall:3.4.0]
> Caused by: java.lang.NullPointerException
> 	at
> org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1432)[org.apache.felix.framework-4.0.3.jar:]
> 	at
> org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
> 	at
> org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:410)[:1.7.0_11]
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)[:1.7.0_11]
> 	at java.lang.Class.forName0(Native Method)[:1.7.0_11]
> 	at java.lang.Class.forName(Class.java:264)[:1.7.0_11]
> 	at
> org.apache.aries.proxy.impl.interfaces.ProxyClassLoader.isInvalid(ProxyClassLoader.java:109)[12:org.apache.aries.proxy.impl:1.0.2]
> 	at
> org.apache.aries.proxy.impl.interfaces.InterfaceProxyGenerator.getProxyInstance(InterfaceProxyGenerator.java:84)[12:org.apache.aries.proxy.impl:1.0.2]
> 	at
> org.apache.aries.proxy.impl.AsmProxyManager.createNewProxy(AsmProxyManager.java:72)[12:org.apache.aries.proxy.impl:1.0.2]
> 	at
> org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingInterceptingProxy(AbstractProxyManager.java:75)[12:org.apache.aries.proxy.impl:1.0.2]
> 	at
> org.apache.aries.proxy.impl.AbstractProxyManager.createDelegatingProxy(AbstractProxyManager.java:40)[12:org.apache.aries.proxy.impl:1.0.2]
> 	at
> org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe.createProxy(AbstractServiceReferenceRecipe.java:338)[7:org.apache.aries.blueprint.core:1.4.0]
> 	at
> org.apache.aries.blueprint.container.ReferenceRecipe.internalCreate(ReferenceRecipe.java:106)[7:org.apache.aries.blueprint.core:1.4.0]/
>
> So apparently no service is found for the specific interface. I find this
> strange since I have several bundles running with Camel and also using the
> ActiveMQ queues in between. Those bundles don't complain of a
> ConnectionFactory missing. 
> I'm assuming I'm missing something to export the service. Is there anybody
> who could point me in the right direction? All help is welcome.
>
> Cheers,
>
> Niels
>
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Retrieve-reference-of-JMS-ConnectionFactory-tp4039259.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

-- 
Krzysztof Sobkowiak

JEE & OSS Architect
Senior Solution Architect @ Capgemini SSC <http://www.pl.capgemini-sdm.com/en>
Apache ServiceMix <http://servicemix.apache.org/> Committer & PMC