High,
I use spring Ioc for the first time in a service layer.
I have succesfully tested this assembly with a new project (console). Now I try to access my service layer from a web project. I've pasted the sections from my first app.config (console) to the web.config, and I get the folowing error :
Error instantiating context
at System.Web.Configuration.HttpConfigurationRecord.E valuate(String configKey, SectionRecord section)
at System.Web.Configuration.HttpConfigurationRecord.G etConfig(String configKey, Boolean cacheResult)
at System.Web.Configuration.HttpConfigurationRecord.G etConfig(String configKey, Boolean cacheResult)
at System.Web.HttpContext.GetConfig(String name)
at System.Web.Configuration.HttpConfigurationSystemBa se.System.Configuration.IConfigurationSystem.GetCo nfig(String configKey)
at System.Configuration.ConfigurationSettings.GetConf ig(String sectionName)
at Spring.Context.Support.ContextRegistry.CreateConte xtIfNeeded()
at Spring.Context.Support.ContextRegistry.GetContext( )
at SuiviPiges.Services.UtilisateurService.GetUsersADN onUtilisateurs()"
Here is the web.config :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context caseSensitive="false" type="Spring.Context.Support.XmlApplicationContext, Spring.Core">
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net" >
<object id="Session" type="SuiviPiges.FmkImpl.Session, SuiviPiges.FmkImpl">
</object>
....
What's wrong ?
Thnaks in advance,
Henri-Pierre
Bruno Baia
11-30-2005, 08:36 AM
Try to use the WebApplicationContext :
http://www.springframework.net/doc/reference/html/web.html#web-configuration
Try to use the WebApplicationContext :
http://www.springframework.net/doc/reference/html/web.html#web-configuration
Thanks for this answer.
I've modified the web.config :
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net" >
<object id="Session" type="SuiviPiges.FmkImpl.Session, SuiviPiges.FmkImpl">
</object>
...
</objects>
</spring>
<system.web>
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</httpHandlers>
<compilation defaultLanguage="vb" debug="true" />
...
... and I've got a new exception now :
[TypeLoadException: Could not load type from string value 'SuiviPiges.FmkImpl.Session, SuiviPiges.FmkImpl']
Spring.Util.TypeResolver.Resolve(String typeName) +318
Spring.Util.CachedTypeResolver.Resolve(String typeName) +173
Spring.Objects.ObjectUtils.ResolveType(String typeName) +24
Spring.Objects.Factory.Support.WebObjectDefinition Factory.CreateObjectDefinition(String typeName, String parent, ConstructorArgumentValues arguments, MutablePropertyValues properties, AppDomain domain) +134
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.ParseObjectDefinition(XmlElement element, String id, XmlResourceReader parser) +238
[ObjectDefinitionStoreException: Error registering object with name 'Session' defined in 'config [objects] at line 21' : Object class [SuiviPiges.FmkImpl.Session, SuiviPiges.FmkImpl] not found.
<object id="Session" type="SuiviPiges.FmkImpl.Session, SuiviPiges.FmkImpl" xmlns="http://www.springframework.net"></obje...]
Spring.Objects.Factory.Xml.XmlResourceReader.Repor tException(XmlNode node, String name, String message, Exception cause) +245
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.ParseObjectDefinition(XmlElement element, String id, XmlResourceReader parser) +1206
Spring.Objects.Factory.Xml.WebObjectDefinitionPars er.ParseObjectDefinition(XmlElement element, String id, XmlResourceReader reader) +37
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.ParseObjectDefinition(XmlElement element, XmlResourceReader parser) +808
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.RegisterObjectDefinition(XmlElement element, XmlResourceReader parser) +15
Spring.Objects.Factory.Xml.DefaultXmlObjectDefinit ionParser.ParseElement(XmlElement element, XmlResourceReader parser) +98
Spring.Objects.Factory.Xml.XmlResourceReader.Regis terObjectDefinitions(XmlElement root) +324
Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er.RegisterObjectDefinitions(XmlElement objectsElement, IResource resource) +122
Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er.LoadObjectDefinitions(IResource resource) +568
Spring.Context.Support.AbstractXmlApplicationConte xt.LoadObjectDefinitions(XmlObjectDefinitionReader objectDefinitionReader) +57
Spring.Context.Support.AbstractXmlApplicationConte xt.RefreshObjectFactory() +94
Spring.Context.Support.AbstractApplicationContext. Refresh() +171
Spring.Context.Support.WebApplicationContext..ctor (String[] configurationLocations) +69
[TargetInvocationException: Une exception a été levée par la cible d'un appel.]
System.Reflection.RuntimeConstructorInfo.InternalI nvoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault) +0
System.Reflection.RuntimeConstructorInfo.Invoke(Bi ndingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +413
Spring.Objects.ObjectUtils.InstantiateType(Constru ctorInfo constructor, Object[] arguments) +46
[FatalObjectException: Cannot instantiate Type [Spring.Context.Support.WebApplicationContext] using ctor [Void .ctor(System.String[])] : 'Une exception a été levée par la cible d'un appel.']
Spring.Web.Support.AbstractHandlerFactory.GetAppli cationContext(HttpContext context)
Spring.Web.Support.PageHandlerFactory.GetHandler(H ttpContext context, String requestType, String url, String path)
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) +691
System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute() +95
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +173
Thanks in advance for your help.
Bruno Baia
11-30-2005, 10:21 AM
Do u referenced the 'SuiviPiges.FmkImpl.dll' in your new Web Project ?
The dll should be in the bin directory of your Web Application.
Do u referenced the 'SuiviPiges.FmkImpl.dll' in your new Web Project ?
The dll should be in the bin directory of your Web Application.
Thank You for this advice, it was a beginner's mistake...
I haven't referenced the dll (I want the web layer to be independant of the implementation) but I have copied the dll in the bin directory, and everything is OK, now.
Thank You again, and have a nice day !
Henri-Pierre
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.