I just ran into a really nasty problem with the way config://spring/objects resource-uris are resolved when using nested WebApplicationContexts (by placing web.config's in my subdirectories)
Say we have the following structure:
with both web.config's containing each a spring/context section referencing the "local" spring/objects section using <resource uri="config://spring/objects" />.Code:Root web.config root.aspx SubDirectory web.config child.aspx
If root.aspx is the first page called after an application-restart, the Root-Context will get instantiated correctly containing all object-definitions from Root/web.config
But: If child.aspx is the first page called after an application-restart, the Root-Context will get instantiated incorrectly with the spring/objects-section of SubDirectory/web-config.
Here's what I found:
For resolving the call to ConfigurationSettings.GetConfig("spring/context") the NET-Runtime calls the ContextHandler 2 times - one for Root/web.config and one for SubDirectory/web.config passing the previously created WebApplicationContext as parent to the SubDirectory's WebApplicationContext. So far so good.
2) Before the SubDirectory's context is created, the Root-Context will be initialized. The problem starts, when the Root-Context tries to resolve the
config://spring/objects resource. This is also done through a call to ConfigurationSettings.GetConfig("spring/objects"). But we're still at the SubDirectory's level!
Thus (+ the fact, that the DefaultSectionHandler ignores any parent-settings), the result of the GetConfig()-call is the "spring/objects"-section of SubDirectory/web.config instead of Root/web.config as expected.
I don't think this behaviour is by intention?
My idea would be to make the WebApplicationContext-Implementation remember the config-file's path, from which it has been constructed and to pass this file to the ConfigSectionResource-implementation. This implementation uses a ConfigurationReader instead of calling ConfigurationSettings.GetConfig().
I'm using the latest nightly build.