aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Przybysz (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ARIES-1715) Blueprint doesn't apply interceptors for the init-method.
Date Fri, 22 Sep 2017 15:10:02 GMT

    [ https://issues.apache.org/jira/browse/ARIES-1715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16176568#comment-16176568
] 

Dominik Przybysz commented on ARIES-1715:
-----------------------------------------

I do not think that this is a bug. init-method is called on bean after its construction, not
on proxy so init method is not transacted yet.

There is better way to handle it. You can create another bean which is transactional and use
it as dependency in init-method of your service. The injected bean will be already proxied.
I have provided PR to your github repository: https://github.com/Smasherr/postconstruct-transactional-test/pull/1

> Blueprint doesn't apply interceptors for the init-method.
> ---------------------------------------------------------
>
>                 Key: ARIES-1715
>                 URL: https://issues.apache.org/jira/browse/ARIES-1715
>             Project: Aries
>          Issue Type: Bug
>          Components: Blueprint
>    Affects Versions: blueprint-core-1.8.2, blueprint-core-1.8.0
>            Reporter: Daniel Estermann
>
> Trying to use an injected entity manager in an init-method results in the following exception:
> {code}
> 2017-04-12T18:10:24,453 | ERROR | Blueprint Extender: 3 | BlueprintContainerImpl    
      | 12 - org.apache.aries.blueprint.core - 1.8.0 | Unable to start blueprint container
for bundle abc.pcta-test/1.0.0.SNAPSHOT
> org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to initialize
bean testBean
> 	at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:738)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:848)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79) [12:org.apache.aries.blueprint.core:1.8.0]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> 	at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88) [12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:255)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:186)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:725)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:412)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:277)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> 	at org.apache.aries.blueprint.container.ExecutorServiceWrapper.run(ExecutorServiceWrapper.java:106)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
[12:org.apache.aries.blueprint.core:1.8.0]
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
> 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
[?:?]
> 	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
[?:?]
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
> 	at java.lang.Thread.run(Thread.java:745) [?:?]
> Caused by: 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.$Proxy80.persist(Unknown Source) ~[?:?]
> 	at Proxya9d42525_1701_4ce9_bbc8_809ae15cb353.persist(Unknown Source) ~[?:?]
> 	at abc.pcta_test.TestBean.init(TestBean.java:28) ~[?:?]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:?]
> 	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
> 	at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)
~[?:?]
> 	at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:980) ~[?:?]
> 	at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:736)
~[?:?]
> 	... 21 more
> {code}
> The following example bundle can be used to reproduce it: https://github.com/Smasherr/postconstruct-transactional-test



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message