Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 360965

Summary: Avoid Spring DM overriding TCCL of scoped applications
Product: [RT] Virgo Reporter: Glyn Normington <glyn.normington>
Component: runtimeAssignee: Glyn Normington <glyn.normington>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dmitry
Version: unspecified   
Target Milestone: 3.5.0.M01   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Bug Depends on: 360671    
Bug Blocks: 361635    

Description Glyn Normington CLA 2011-10-14 09:39:03 EDT
The new testcase SyntheticContextTCCLIntegrationTests since Virgo carefully sets up the TCCL for a bundle in one of Virgo's "scopes" before issuing Bundle.start and we have a special executor
configured into Spring DM to make sure the TCCL gets propagated to
Spring DM's worker threads, but then Spring DM overrides the TCCL
with the bean class loader, as described in the Spring DM reference ([1]).

It may be possible to fix avoid this in one of the following ways:

1. create and set a ContextClassLoaderProvider that uses only the TCCL.
2. set as null the BeanClassLoader of the DefaultContextClassLoaderProvider so that it will fall back to the TCCL.

[1] http://static.springsource.org/osgi/docs/1.2.x/reference/html-single/#app-deploy:ext-libs
Comment 1 Dmitry Sklyut CLA 2011-10-14 10:24:47 EDT
(In reply to comment #0)
Aha!  Moment!

I would vote for a special OsgiApplicationContextCreator in addition to ContextClassLoaderProvider.
This way virgo will be in full control of the ApplicationContext creation.

There is also few spring 3.x missing features in spring dm that can be implemented if OsgiApplicationContextCreator is managed by Virgo.  Namely BeanDefinitionRegistryPostProcessor that was added in spring 3.x.
Comment 2 Glyn Normington CLA 2011-10-14 10:28:40 EDT
(In reply to comment #1)
Sounds good. A patch, or even a suggestion of where to start, would be gratefully received. Although I work for SpringSource, my brain is far too small to fit in Spring and its best practices. ;-)
Comment 3 Glyn Normington CLA 2011-10-17 07:29:45 EDT
Kernel commit 7c7c26987a56cbd812eaa098a513d0be211636a6 introduces an OsgiApplicationContextCreator for the user region. Currently, this simply extends DefaultOsgiApplicationContextCreator and delegates createApplicationContext to super.
Comment 4 Glyn Normington CLA 2011-10-20 07:31:57 EDT
Kernel commit 1f4aaf837ba7431b54d958fc89920787494b70c7 sets a ContextClassLoaderProvider which preserves existing TCCLs. SyntheticContextTCCLIntegrationTests now passes and is enabled.
Comment 5 Glyn Normington CLA 2011-10-20 07:41:04 EDT
Documentation commit ed5a500af21c94d4caf1de04bc36444aeeb26ddf removes the corresponding known issue.
Comment 6 Glyn Normington CLA 2012-03-01 11:28:23 EST
Note that this fix affects certain applications that rely on the bug. See bug 368781 for an example.

I added a migration note ([1]) to alert users to this.

[1] http://wiki.eclipse.org/Virgo/Community/Migrating_from_3.0.x_to_3.5.0#Thread_Context_Class_Loading_with_PARs_and_Scoped_Plans