Bug 1149672 - BeanManagerProvider in deltaspike-core-api bundle references CDI containers of already uninstalled bundles
Summary: BeanManagerProvider in deltaspike-core-api bundle references CDI containers o...
Keywords:
Status: MODIFIED
Alias: None
Product: JBoss Fuse Service Works 6
Classification: JBoss
Component: SwitchYard
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
: ---
Assignee: Tomohisa Igarashi
QA Contact: Matej Melko
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-06 12:47 UTC by Martin Basovník
Modified: 2016-12-01 00:55 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)
reproducer (15.52 KB, application/zip)
2014-11-04 12:18 UTC, Martin Basovník
no flags Details


Links
System ID Priority Status Summary Last Updated
JBoss Issue Tracker SWITCHYARD-2372 Critical Closed BeanManagerProvider in deltaspike-core-api bundle references CDI containers of already uninstalled bundles 2016-01-21 16:55:44 UTC

Description Martin Basovník 2014-10-06 12:47:20 UTC
=== Description of problem:

BeanManagerProvider in deltaspike-core-api bundle references CDI containers of already uninstalled bundles.

https://github.com/apache/deltaspike/blob/deltaspike-0.4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java#L96

We can face serious problem if we use current version of arquillian-osgi-container. Arquillian bundle undeploys tested bundle but it holds old classloader because tested bundle was not uninstalled properly (deltaspike-core-api has reference to its classloader). When we execute arquillian test second time it can fail in the following place if some special conditions occurs:

https://github.com/jboss-switchyard/core/blob/2.0.0.Alpha3/bus/camel/src/main/java/org/switchyard/bus/camel/CamelMessage.java#L76


=== Version-Release number of selected component (if applicable):
FSW 6.1 DR2


=== Steps to Reproduce:

1. Start karaf in debug mode
2. Put a breakpoint here:
https://github.com/apache/deltaspike/blob/deltaspike-0.4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java#L152
3. Attach your debugger to karaf in Eclipse
4. Install a switchyard quickstart
=> You will see new item in private map bmInfos in BeanManagerProvider
5. Uninstall quickstart
6. Install it again
=> Now we have two CDI containers for our quickstart and some bundles can use the old one. It can result in ClassCastException...


=== Actual results:

SWITCHYARD010813: Cannot convert from 'XXX' to 'XXX'. No registered Transformer available for transforming from 'XXX' to 'XXX'. A Transformer must be registered.

Comment 1 Tomohisa Igarashi 2014-10-31 09:15:08 UTC
I didn't see that behavior on current upstream master + karaf 2.3.5.

Comment 2 Martin Basovník 2014-11-03 08:09:04 UTC
I have reproduced this issue on karaf 2.3.8 + SwitchYard SNAPSHOT (2014-11-03):

=== Step 4: 
bmpSingleton.bmInfos.toString()

{BundleClassLoader{bundle=[DelegatingBundle: [org.switchyard.quickstarts.switchyard.bean.service [192], org.ops4j.pax.cdi.weld [118], org.jboss.weld.osgi-bundle [116], org.switchyard.components.switchyard-component-bean [161], org.apache.deltaspike.core.deltaspike-core-api [119]]],parent=null}=org.apache.deltaspike.core.api.provider.BeanManagerProvider$BeanManagerInfo@7f99a13b}

=== Step 6: 
bmpSingleton.bmInfos.toString()

{BundleClassLoader{bundle=[DelegatingBundle: [org.switchyard.quickstarts.switchyard.bean.service [193], org.ops4j.pax.cdi.weld [118], org.jboss.weld.osgi-bundle [116], org.switchyard.components.switchyard-component-bean [161], org.apache.deltaspike.core.deltaspike-core-api [119]]],parent=null}=org.apache.deltaspike.core.api.provider.BeanManagerProvider$BeanManagerInfo@595ca8d6, BundleClassLoader{bundle=[DelegatingBundle: [org.switchyard.quickstarts.switchyard.bean.service [192], org.ops4j.pax.cdi.weld [118], org.jboss.weld.osgi-bundle [116], org.switchyard.components.switchyard-component-bean [161], org.apache.deltaspike.core.deltaspike-core-api [119]]],parent=null}=org.apache.deltaspike.core.api.provider.BeanManagerProvider$BeanManagerInfo@7f99a13b}

Why there is a reference to bundle 192 in step 6? This bundle is already uninstalled.

Comment 3 Tomohisa Igarashi 2014-11-03 17:36:48 UTC
OK, I could see it. But can you provide a reproducer for the actual issue? It shouldn't be a problem as BundleClassLoader is different for each app for normal use.

Comment 4 Martin Basovník 2014-11-04 12:18:37 UTC
Created attachment 953582 [details]
reproducer

Steps to reproduce:
1. Restart JBoss Fuse
2. mvn clean verify  => OK
3. mvl clean verify  => ERROR

Caused by: org.switchyard.HandlerException: org.switchyard.SwitchYardException: SWITCHYARD010813: Cannot convert from 'org.jboss.soa.qa.transform.dozer.domain.OrderDomain' to 'org.jboss.soa.qa.transform.dozer.domain.OrderDomain'.  No registered Transformer available for transforming from 'java:org.jboss.soa.qa.transform.dozer.domain.OrderDomain' to 'java:org.jboss.soa.qa.transform.dozer.domain.OrderDomain'.  A Transformer must be registered.
	at org.switchyard.handlers.ProviderHandler.handleMessage(ProviderHandler.java:73)
...

Comment 5 Tomohisa Igarashi 2014-11-04 13:20:23 UTC
* It couldn't run against karaf 2.3.8 [1].
* DozerTransformationTest is specified as bean implementation, but no @Service annotation.
* And DozerTransformationTest is in test scope.

Isn't it reproduced without arquillian? if it happens only with arquillian, please report it against arquillian. FYI, we are using pax exam instead for our release tests on karaf.
https://github.com/jboss-switchyard/release/tree/master/karaf/tests


[1]
java.lang.IllegalStateException: java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at org.jboss.arquillian.container.osgi.jmx.JMXDeployableContainer.getMBeanProxy(JMXDeployableContainer.java:347)
...
Caused by: java.lang.NullPointerException
        at org.jboss.arquillian.container.osgi.jmx.JMXDeployableContainer$2.call(JMXDeployableContainer.java:328)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

Comment 6 Tomohisa Igarashi 2014-11-04 13:37:05 UTC
FYI2, BeanManagerInfo is expected to be removed here, but it fails on karaf as TCCL is not the BundleClassLoader when BeforeShutdown event is sent.
https://github.com/apache/deltaspike/blob/deltaspike-1.0.0/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/provider/BeanManagerProvider.java#L248

Comment 7 Tomohisa Igarashi 2014-11-28 14:39:49 UTC
I verified BeanManagerInfo is successfully removed on BeforeShutdown event with this fix:
https://github.com/igarashitm/org.ops4j.pax.cdi/commit/d7761d38bcef49e26b4290861da276c8bdce7bb0

I'm not sure if it's acceptable for PAX CDI though.

Comment 8 Tomohisa Igarashi 2014-12-16 07:14:35 UTC
Filed a JIRA against PAXCDI and attached a pull request - https://ops4j1.jira.com/browse/PAXCDI-143

Comment 9 JBoss JIRA Server 2015-07-08 04:17:24 UTC
Tomohisa igarashi <tm.igarashi@gmail.com> updated the status of jira SWITCHYARD-2372 to Closed

Comment 12 JBoss JIRA Server 2015-11-05 16:27:22 UTC
Tom Cunningham <tcunning@redhat.com> updated the status of jira SWITCHYARD-2372 to Reopened

Comment 13 JBoss JIRA Server 2015-11-05 16:27:34 UTC
Tom Cunningham <tcunning@redhat.com> updated the status of jira SWITCHYARD-2372 to Closed


Note You need to log in before you can comment on or make changes to this bug.