PDA

View Full Version : classical error: instantiating context 'spring.root'


boriska
04-04-2007, 03:46 PM
I don’t understand what the issue is….
I only added new object and a new service object that references to it.

There are another objects and services and they worked, this new insert is analog...

The error says : TypeLoadException: Could not load type from string value ‘className,AssemblyName’
If I ‘m using the reflector, I can see that class is in the assembly

Here the call stack:


[TypeLoadException: Der Typ Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice in der Assembly DataAccessLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null konnte nicht geladen werden.]
System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +0
Spring.Util.TypeResolver.LoadTypeDirectlyFromAssem bly(TypeAssemblyInfo typeInfo) +133
Spring.Util.TypeResolver.ResolveType(String typeName) +179

[TypeLoadException: Could not load type from string value 'Serad.VBP2.DataAccessLayer.Spring.Services.Filter Sevice, DataAccessLayer'.]
Spring.Util.TypeResolver.ResolveType(String typeName) +214
Spring.Util.TypeResolver.Resolve(String typeName) +97
Spring.Util.CachedTypeResolver.Resolve(String typeName) +340
Spring.Objects.ObjectUtils.ResolveType(String typeName) +92
Spring.Objects.Factory.Support.DefaultObjectDefini tionFactory.CreateObjectDefinition(String typeName, String parent, ConstructorArgumentValues arguments, MutablePropertyValues properties, AppDomain domain) +106
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.ParseObjectDefinition(XmlElement element, String id, XmlResourceReader parser) +569

[ObjectDefinitionStoreException: Error registering object with name 'FilterService' defined in 'file [D:\Development\VBP_Online\VBP2\WebSites\Developmen tWebsite\Services.xml]' : Object class [Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice, DataAccessLayer] not found.
<object id="FilterService" type="Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice, DataAccessLayer" xmlns="http://www.springframework.net"><property name="FilterServiceGetter" ref="filterStoredProc" /></object>]
Spring.Objects.Factory.Xml.XmlResourceReader.Repor tException(XmlNode node, String name, String message, Exception cause) +414
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.ParseObjectDefinition(XmlElement element, String id, XmlResourceReader parser) +1778
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.ParseObjectDefinition(XmlElement element, XmlResourceReader parser) +284
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.RegisterObjectDefinition(XmlElement element, XmlResourceReader parser) +81

[ObjectDefinitionStoreException: Failed parsing object definition '<object id="FilterService" type="Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice, DataAccessLayer" xmlns="http://www.springframework.net"><property name="FilterServiceGetter" ref="filterStoredProc" /></object>']
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.RegisterObjectDefinition(XmlElement element, XmlResourceReader parser) +194
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.ParseElement(XmlElement element, XmlResourceReader parser) +171
Spring.Objects.Factory.Xml.XmlResourceReader.Regis terObjectDefinitions(XmlElement root) +371
Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er.RegisterObjectDefinitions(XmlElement objectsElement, IResource resource) +74
Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er.LoadObjectDefinitions(IResource resource) +540
Spring.Context.Support.AbstractXmlApplicationConte xt.LoadObjectDefinitions(XmlObjectDefinitionReader objectDefinitionReader) +156
Spring.Context.Support.AbstractXmlApplicationConte xt.RefreshObjectFactory() +128
Spring.Context.Support.AbstractApplicationContext. Refresh() +265
Spring.Context.Support.XmlApplicationContext..ctor (String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations) +73
Spring.Context.Support.XmlApplicationContext..ctor (String name, Boolean caseSensitive, String[] configurationLocations) +55

[TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht.]
System.RuntimeMethodHandle._InvokeConstructor(Obje ct[] args, SignatureStruct& signature, IntPtr declaringType) +0
System.RuntimeMethodHandle.InvokeConstructor(Objec t[] args, SignatureStruct signature, RuntimeTypeHandle declaringType) +13
System.Reflection.RuntimeConstructorInfo.Invoke(Bi ndingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +366
System.Reflection.ConstructorInfo.Invoke(Object[] parameters) +14
Spring.Objects.ObjectUtils.InstantiateType(Constru ctorInfo constructor, Object[] arguments) +311

[FatalObjectException: Cannot instantiate Type [Spring.Context.Support.XmlApplicationContext] using ctor [Void .ctor(System.String, Boolean, System.String[])] : 'Ein Aufrufziel hat einen Ausnahmefehler verursacht.']
Spring.Objects.ObjectUtils.InstantiateType(Constru ctorInfo constructor, Object[] arguments) +499
Spring.Context.Support.RootContextInstantiator.Inv okeContextConstructor(ConstructorInfo ctor) +198
Spring.Context.Support.ContextInstantiator.Instant iateContext() +200

[ConfigurationErrorsException: Error instantiating context 'spring.root'.]
System.Configuration.BaseConfigurationRecord.Evalu ateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) +358
System.Configuration.BaseConfigurationRecord.Evalu ate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) +988
System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) +1451
System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) +1451
System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey, Boolean getLkg, Boolean checkPermission) +67
System.Configuration.BaseConfigurationRecord.GetSe ction(String configKey) +34
System.Web.HttpContext.GetSection(String sectionName) +62
System.Web.Configuration.HttpConfigurationSystem.G etSection(String sectionName) +46
System.Web.Configuration.HttpConfigurationSystem.S ystem.Configuration.Internal.IInternalConfigSystem .GetSection(String configKey) +29
System.Configuration.ConfigurationManager.GetSecti on(String sectionName) +59
Spring.Util.ConfigurationUtils.GetSection(String sectionName) +44
Spring.Context.Support.ContextRegistry.InitializeC ontextIfNeeded() +66
Spring.Context.Support.ContextRegistry.GetContext( ) +72
Spring.Data.NHibernate.Support.OpenSessionInViewMo dule.get_SessionFactory() +66
Spring.Data.NHibernate.Support.OpenSessionInViewMo dule.Open() +82
Spring.Data.NHibernate.Support.OpenSessionInViewMo dule.context_BeginRequest(Object sender, EventArgs e) +45
System.Web.SyncEventExecutionStep.System.Web.HttpA pplication.IExecutionStep.Execute() +167
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +117

Bruno Baia
04-04-2007, 10:36 PM
Hi,

Is the assembly DataAccessLayer.dll in the bin directory ?


Bruno

boriska
04-05-2007, 09:47 AM
Hello Bruno,

yes, of course. The strangest thing is that if I skip the new objects then all will work fine... However these new objects were build in the same art as older...



Thanks anyway
Boris

Nop
04-05-2007, 10:21 AM
Hi Boris.

[TypeLoadException: Der Typ Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice in der Assembly DataAccessLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null konnte nicht geladen werden.]
What does it mean in English?

However these new objects were build in the same art as older...
Did you declare "older" objects in the spring context configuration from DataAccessLayer assembly or from another?

Can you show declaration of your "older" and "newer" objects in the configuration file?

Validate again types of objects in context and names of classes... In my case there are typo errors :) .

Best regards,
Nop

boriska
04-05-2007, 12:05 PM
Hello Nop,

sorry, that means "type ... could not be loaded". But as I said, there is that class in the assembly.

How can I "debug" my issue else?

Here are some extracts from dao.xml and then services.xml:
<object id="engagementsStoredProc" type="Serad.VBP2.DataAccessLayer.Spring.DAO.ADOStoredPro cs.EngagementsStoredProc, DataAccessLayer">
<constructor-arg index="0" ref="DbProvider"/>
</object>
<object id="filterStoredProc" type="Serad.VBP2.DataAccessLayer.Spring.DAO.ADOStoredPro cs.FilterStoredProc, DataAccessLayer">
<constructor-arg index="0" ref="DbProvider"/>
</object>

<object id ="EngagementService" type="Serad.VBP2.DataAccessLayer.Spring.Services.Engagem entSevice, DataAccessLayer">
<property name="Engagement_DAO_AT" ref="engagementsStoredProc" />
</object>

<object id ="FilterService" type="Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice, DataAccessLayer">
<property name="FilterStoredProc" ref="filterStoredProc" />
</object>

I looked shortly into the blog of Scott Bellware and found an interesting approach
http://codebetter.com/blogs/scott.bellware/archive/2006/10/20/150642.aspx

Could anyone from spring.net team say if there are any enhancements towards type safe spring.net configurations planned?


Regards,
Boris

boriska
04-05-2007, 03:31 PM
I don't understand: it is very strange- I added a new service class( the same code as for the older one') , referenced it to an existing object and all worked fine. .Net bug?!

But as I said, having a type safe configuration option would reduce this sort of errors

Bruno Baia
04-05-2007, 10:17 PM
I don't understand: it is very strange- I added a new service class( the same code as for the older one') , referenced it to an existing object and all worked fine. .Net bug?!

But as I said, having a type safe configuration option would reduce this sort of errors
type safe configuration will not help here, the cast will be done anyway, see this discussion we got a long time ago :
New Feature? cxt.GetObject<T>() (http://forum.springframework.net/showthread.php?t=366)


Bruno

Bruno Baia
04-05-2007, 10:27 PM
About the error, it's pretty clear : The type does not exist in the assembly DataAccessLayer.dll located in the bin directory.
You should check the type name letter by letter :D


Bruno

Bruno Baia
04-05-2007, 10:30 PM
Oki, maybe I got it :

Serad.VBP2.DataAccessLayer.Spring.Services.FilterS ervice
instead of
Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice

and

Serad.VBP2.DataAccessLayer.Spring.Services.FilterS ervice
instead of
Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice


- Bruno

boriska
04-07-2007, 11:06 AM
Hello Bruno,

all you have recited, had to do with copy-paste, it was always

Serad.VBP2.DataAccessLayer.Spring.Services.FilterS ervice
Serad.VBP2.DataAccessLayer.Spring.Services.FilterS ervice

I mentioned in my first posting to this topic that I was using the reflector and the missing class was in the assembly and the assembly was in the bin folder. I was surprised by that, it's all. I deleted all files in the Temporary ASP.NET Files-folder and the bin, did rebuild the solution, but that didn't fix the issue.
That was the only reason for me to ask for an instrument that can handle("debug") this art of errors more precisely.

Oki, maybe I got it :

Serad.VBP2.DataAccessLayer.Spring.Services.FilterS ervice
instead of
Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice

and

Serad.VBP2.DataAccessLayer.Spring.Services.FilterS ervice
instead of
Serad.VBP2.DataAccessLayer.Spring.Services.FilterS evice


- Bruno

Regards,
Boris