Question

I have the weirdest problem with Spring.net, when trying to convert my project from .NET 3.5 to .NET 4.

Let me summarise our architecture: Project A (not under my control) has a Sprint.Net config referencing a setting (configurationProvider.url) like this:

<constructor-arg name="Url" value="${configurationProvider.url}" />

Project B (my project, under my control) has another config file with the value of this setting:

<configuration>
  <Environment>
    <add key="Dashboard.Environment"      value="UAT" />
    <add key="configurationProvider.url"  value="http://something/ConfigurationProvider.asmx"/>
    <add key="pkicheck.url"               value="http://something/webservices/pkicheck.asmx"/>
    <add key="sso.url"                    value="http://something/webservices/ssoclient.asmx"/>
  </Environment>
</configuration>

It all works very well when Project B was .NET 3.5. When converting this project to .NET 4 (and that's the only change), the whole thing starts failing, and it's giving me this exception:

Could not resolve placeholder 'configurationProvider.url'

It is obviously not finding the configuration setting on the ProjectB configuration file, although this file is there and contains the value. What could have changed between 3.5 and 4?

Full exception:

<ConfigurationErrorsException d1p1:type="ConfigurationErrorsException">
 <ClassName>System.Configuration.ConfigurationErrorsException</ClassName>
 <Message>Error creating context 'spring.root': Error registering object with name 'configurationProvider' defined in 'assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111' : Could not resolve placeholder 'configurationProvider.url'.</Message>
 <Data d1p1:type="IDictionary"/>
<InnerException d1p1:type="Exception">
 <ClassName>Spring.Objects.Factory.ObjectDefinitionStoreException</ClassName>
 <Message>Error registering object with name 'configurationProvider' defined in 'assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111' : Could not resolve placeholder 'configurationProvider.url'.</Message>
 <Data d1p1:type="IDictionary"/>
 <InnerException d1p1:type="Exception"/>
 <HelpURL/>
 <StackTraceString> at Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer.ProcessProperties(IConfigurableListableObjectFactory factory, NameValueCollection props) at Spring.Objects.Factory.Config.PropertyResourceConfigurer.PostProcessObjectFactory(IConfigurableListableObjectFactory factory) at Spring.Context.Support.AbstractApplicationContext.ProcessObjectFactoryPostProcessors(IList objectFactoryPostProcessors) at Spring.Context.Support.AbstractApplicationContext.InvokeObjectFactoryPostProcessors() at Spring.Context.Support.AbstractApplicationContext.Refresh() at Spring.Context.Support.XmlApplicationContext..ctor(Boolean refresh, String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations) at Spring.Context.Support.XmlApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) at _dynamic_Spring.Context.Support.XmlApplicationContext..ctor(Object[] ) at Spring.Reflection.Dynamic.SafeConstructor.Invoke(Object[] arguments) at Spring.Context.Support.ContextHandler.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) at Spring.Context.Support.ContextHandler.ContextInstantiator.InstantiateContext() at Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) at Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section)</StackTraceString>
 <RemoteStackTraceString/>
 <RemoteStackIndex>0</RemoteStackIndex>
 <ExceptionMethod>8 ProcessProperties Spring.Core, Version=1.3.0.20349, Culture=neutral, PublicKeyToken=65e474d141e25e07 Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer Void ProcessProperties(Spring.Objects.Factory.Config.IConfigurableListableObjectFactory, System.Collections.Specialized.NameValueCollection)</ExceptionMethod>
 <HResult>-2146232832</HResult>
 <Source>Spring.Core</Source>
 <WatsonBuckets d1p1:type="System.Byte"d1p1:includeArrayAttribute="true"/>
 <_resourceDescription>assembly [ProjectA.Core, Version=0.0.0.88, Culture=neutral, PublicKeyToken=1b28b51fb20f454e], resource [ProjectA.Core.Framework.config] line 111</_resourceDescription>
 <_objectName>configurationProvider</_objectName>
 </InnerException>
 <HelpURL/>
 <StackTraceString> at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at Spring.Util.ConfigurationUtils.GetSection(String sectionName) at Spring.Context.Support.ContextRegistry.InitializeContextIfNeeded() at Spring.Context.Support.ContextRegistry.GetContext() at ProjectA.Core.Controller.Initialise(String flavour) in d:\TeamCity8100\buildAgent\work\850180d7b576030f\Code\Src\ProjectA\Framework\Core\Controller.cs:line 238</StackTraceString>
 <RemoteStackTraceString/>
 <RemoteStackIndex>0</RemoteStackIndex>
 <ExceptionMethod>8 EvaluateOne System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a System.Configuration.BaseConfigurationRecord System.Object EvaluateOne(System.String[], System.Configuration.SectionInput, Boolean, System.Configuration.FactoryRecord, System.Configuration.SectionRecord, System.Object)</ExceptionMethod>
 <HResult>-2146232062</HResult>
 <Source>System.Configuration</Source>
 <WatsonBuckets d1p1:type="System.Byte"d1p1:includeArrayAttribute="true"/>
 <filename d1p1:type="Object"/>
 <line>0</line>
 <firstFilename d1p1:type="Object"/>
 <firstLine>0</firstLine>
 <count>0</count>
 </ConfigurationErrorsException>
Was it helpful?

Solution

I eventually found the problem. We use PropertyPlaceholderConfigurer in our config, and we never set an "Order" property. So Spring was "ordering" on Order, but since Order was always equal to int.Max, the order output was non-deterministic.

Adding Order to the config file fixed it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top