Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360965 - Avoid Spring DM overriding TCCL of scoped applications
Summary: Avoid Spring DM overriding TCCL of scoped applications
Status: CLOSED FIXED
Alias: None
Product: Virgo
Classification: RT
Component: runtime (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.5.0.M01   Edit
Assignee: Glyn Normington CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 360671
Blocks: 361635
  Show dependency tree
 
Reported: 2011-10-14 09:39 EDT by Glyn Normington CLA
Modified: 2012-03-01 11:28 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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