Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Fixed
-
blueprint-core-1.9.0
-
None
-
Karaf 4.2.0
Description
I have committed a project on Github to illustrate the issue : https://github.com/nicolas-dutertry/test-jpa
This project contains a blueprint bundle with a bean TestRepository annotated with @PersistenceContext. This bean is then injected into another bean TestServiceImpl which is then published as an osgi service :
<jpa:enable/> <tx:enable/> <!-- This bean contains a @PersistenceContext EntityManager --> <bean id="testRepository" class="com.dutertry.test.karaf.jpa.service.impl.TestRepository"/> <bean id="testService" class="com.dutertry.test.karaf.jpa.service.impl.TestServiceImpl"> <property name="testRepository" ref="testRepository"/> </bean> <service interface="com.dutertry.test.karaf.jpa.service.TestService" ref="testService"/>
With Karaf 4.1.5 the instance of TestRepository injected in testService is an aries proxy managing JPA stuff, but with Karaf 4.2.0 the injected instance is not a proxy. Thus when using testService, the following error occurs:
java.lang.IllegalStateException: Need active coordination at org.apache.aries.jpa.support.impl.EMSupplierImpl.get(EMSupplierImpl.java:81) ~[?:?] at org.apache.aries.jpa.support.osgi.impl.EmProxy.invoke(EmProxy.java:38) ~[?:?] at com.sun.proxy.$Proxy77.createQuery(Unknown Source) ~[?:?] at Proxy4c2993b8_dc6f_46b4_8e62_524dc0ad05f5.createQuery(Unknown Source) ~[?:?] at com.dutertry.test.karaf.jpa.service.impl.TestRepository.list(TestRepository.java:26) ~[?:?] at com.dutertry.test.karaf.jpa.service.impl.TestServiceImpl.list(TestServiceImpl.java:25) ~[?:?] at com.dutertry.test.karaf.jpa.cmd.ListPersonCommand.execute(ListPersonCommand.java:24) ~[?:?] at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84) ~[?:?] at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68) ~[?:?] at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86) ~[?:?] at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571) ~[?:?] at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497) ~[?:?] at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386) ~[?:?] at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417) ~[?:?] at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?] at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:?] at java.lang.Thread.run(Thread.java:748) [?:?]
After some investigation, I have found that this bug is due to the resolution of issue ARIES-1544. I have done a patch (see attached file) which solve the issue I think.
Can you please integrate my patch or correct the issue another way ?
Attachments
Attachments
Issue Links
- blocks
-
ARIES-1869 Example does not work with current karaf 4.2.1
- Resolved
- links to