Injecting transaction in OSGi reference listener with blueprint -


i have osgi bundle has reference listener class keeping track of services registered other osgi bundles. have configured reference listener blueprint follows , have deployed necessary aries bundles in felix:

<?xml version="1.0" encoding="utf-8" standalone="no"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0" xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">       <reference-list id="servicelist" interface="com.test.myservice" availability="optional">         <reference-listener bind-method="bind" unbind-method="unbind">             <bean class="com.test.myservicemonitor" />         </reference-listener>     </reference-list> </blueprint> 

everything works configuration , bind , unbind methods of myservicemonitor class called when services come , go. next step want bind method write data in database tried inject entity manager in myservicemonitor , create transaction changing bean tag follows:

<bean class="com.test.myservicemonitor">     <tx:transaction method="bind" value="requiresnew" />     <jpa:context property="entitymanager" unitname="myunit" /> </bean> 

this attempt create transaction bind method results exception below when start bundle. bundle started without problems when remove tx:transaction tag while have been able use entity manager , transactions in other (non reference listener) beans same blueprint configuration.

being relatively new osgi haven't been able figure out whether expected behaviour , if yes proper way perform db operations inside reference listener. insights on that?

2013-07-11 12:40:12,592 | error | 20 - org.apache.aries.blueprint - 1.1.0 | org.apache.aries.blueprint.container.blueprintcontainerimpl | unable start blueprint container bundle com.test.my-bundle org.osgi.service.blueprint.container.componentdefinitionexception: unable convert value beanrecipe[name='#recipe-2'] type class java.lang.object     @ org.apache.aries.blueprint.di.collectionrecipe.internalcreate(collectionrecipe.java:92)     @ org.apache.aries.blueprint.di.abstractrecipe.create(abstractrecipe.java:106)     @ org.apache.aries.blueprint.container.abstractservicereferencerecipe.createlisteners(abstractservicereferencerecipe.java:246)     @ org.apache.aries.blueprint.container.referencelistrecipe.internalcreate(referencelistrecipe.java:74)     @ org.apache.aries.blueprint.di.abstractrecipe$1.call(abstractrecipe.java:79)     @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:334)     @ java.util.concurrent.futuretask.run(futuretask.java:166)     @ org.apache.aries.blueprint.di.abstractrecipe.create(abstractrecipe.java:88)     @ org.apache.aries.blueprint.container.blueprintrepository.createinstances(blueprintrepository.java:245)     @ org.apache.aries.blueprint.container.blueprintrepository.createall(blueprintrepository.java:183)     @ org.apache.aries.blueprint.container.blueprintcontainerimpl.instantiateeagercomponents(blueprintcontainerimpl.java:668)     @ org.apache.aries.blueprint.container.blueprintcontainerimpl.dorun(blueprintcontainerimpl.java:370)     @ org.apache.aries.blueprint.container.blueprintcontainerimpl.run(blueprintcontainerimpl.java:261)     @ java.util.concurrent.executors$runnableadapter.call(executors.java:471)     @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:334)     @ java.util.concurrent.futuretask.run(futuretask.java:166)     @ org.apache.aries.blueprint.container.executorservicewrapper.run(executorservicewrapper.java:106)     @ org.apache.aries.blueprint.utils.threading.impl.discardablerunnable.run(discardablerunnable.java:48)     @ java.util.concurrent.executors$runnableadapter.call(executors.java:471)     @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:334)     @ java.util.concurrent.futuretask.run(futuretask.java:166)     @ java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.access$201(scheduledthreadpoolexecutor.java:178)     @ java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run(scheduledthreadpoolexecutor.java:292)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1110)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:603)     @ java.lang.thread.run(thread.java:722) caused by: org.osgi.service.blueprint.container.componentdefinitionexception: error setting property: propertydescriptor <name: listener, getter: null, setter: [class org.apache.aries.blueprint.container.abstractservicereferencerecipe$listener.setlistener(class java.lang.object)]     @ org.apache.aries.blueprint.container.beanrecipe.setproperty(beanrecipe.java:941)     @ org.apache.aries.blueprint.container.beanrecipe.setproperties(beanrecipe.java:907)     @ org.apache.aries.blueprint.container.beanrecipe.setproperties(beanrecipe.java:888)     @ org.apache.aries.blueprint.container.beanrecipe.internalcreate2(beanrecipe.java:820)     @ org.apache.aries.blueprint.container.beanrecipe.internalcreate(beanrecipe.java:787)     @ org.apache.aries.blueprint.di.abstractrecipe.create(abstractrecipe.java:106)     @ org.apache.aries.blueprint.di.collectionrecipe.internalcreate(collectionrecipe.java:90)     ... 25 more caused by: org.osgi.service.blueprint.container.componentdefinitionexception: unable create proxy bean #recipe-3 in bundle com.test.my-bundle version 1.0.0.snapshot     @ org.apache.aries.blueprint.container.beanrecipe.addinterceptors(beanrecipe.java:771)     @ org.apache.aries.blueprint.container.beanrecipe.wrap(beanrecipe.java:841)     @ org.apache.aries.blueprint.container.aggregateconverter.convert(aggregateconverter.java:149)     @ org.apache.aries.blueprint.container.blueprintrepository.convert(blueprintrepository.java:402)     @ org.apache.aries.blueprint.utils.reflectionutils$propertydescriptor.convert(reflectionutils.java:394)     @ org.apache.aries.blueprint.utils.reflectionutils$methodpropertydescriptor.internalset(reflectionutils.java:628)     @ org.apache.aries.blueprint.utils.reflectionutils$propertydescriptor.set(reflectionutils.java:378)     @ org.apache.aries.blueprint.container.beanrecipe.setproperty(beanrecipe.java:939)     ... 31 more caused by: org.apache.aries.proxy.unabletoproxyexception: class com.test.myservicemonitor not interface , therefore proxy cannot generated.     @ org.apache.aries.proxy.impl.jdkproxymanager.getinterfaces(jdkproxymanager.java:43)     @ org.apache.aries.proxy.impl.jdkproxymanager.createnewproxy(jdkproxymanager.java:36)     @ org.apache.aries.proxy.impl.abstractproxymanager.createdelegatinginterceptingproxy(abstractproxymanager.java:75)     @ org.apache.aries.proxy.impl.abstractproxymanager.createinterceptingproxy(abstractproxymanager.java:53)     @ org.apache.aries.blueprint.container.beanrecipe.addinterceptors(beanrecipe.java:767)     ... 38 more 

your transaction manager using jdkproxymanager proxy transactions. built in jdk proxy manager requires interface in order proxy. best bet make interface required methods , implement it. other option switch asm, cglib or javaassist based proxymanager.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -