=== 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.
I didn't see that behavior on current upstream master + karaf 2.3.5.
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.
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.
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) ...
* 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)
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
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.
Filed a JIRA against PAXCDI and attached a pull request - https://ops4j1.jira.com/browse/PAXCDI-143
Tomohisa igarashi <tm.igarashi> updated the status of jira SWITCHYARD-2372 to Closed
Tom Cunningham <tcunning> updated the status of jira SWITCHYARD-2372 to Reopened
Tom Cunningham <tcunning> updated the status of jira SWITCHYARD-2372 to Closed
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.