PDA

View Full Version : Error loading ApplicationContext


pcorp
12-29-2004, 06:38 PM
I have a very simple app context file as follows:

<?xml version="1.0" encoding="utf-8" ?>
<objects>
<object id="userData" type="CDICommon.Model.Security.UserData, CDICommon"/>
</objects>

When I try to load as follows:

IApplicationContext appCtx = new FileSystemXmlApplicationContext(@"C:\CogentWorkspace\CDIClient\bin\Debug\projectPlug in.xml");

I get the following stack trace:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ApplicationException: Object definition does not carry a resolved object class
at Spring.Objects.Factory.Support.AbstractObjectDefin ition.get_ObjectClass()
at Spring.Objects.Factory.Support.DefaultListableObje ctFactory.GetObjectDefinitionNames(Type type)
at Spring.Context.Support.AbstractApplicationContext. GetObjectDefinitionNames(Type type)
at Spring.Context.Support.AbstractApplicationContext. invokeObjectFactoryPostProcessors()
at Spring.Context.Support.AbstractApplicationContext. Refresh()
at Spring.Context.Support.FileSystemXmlApplicationCon text..ctor(String[] configurationLocations)
at Spring.Context.Support.FileSystemXmlApplicationCon text..ctor(String configurationLocation)
at CDIClient.Plugins.Project.ProjectPluginWrapper.Ini t() in c:\cogentworkspace\cdiclient\plugins\project\proje ctpluginwrapper.cs:line 32

I have verified that the UserData class is in the CDICommon assembly and all the paths are correct. Any idea what is causing this? Any help would be most appreciated. Thanks.

--pcorp

Mark Pollack
12-29-2004, 11:13 PM
Hi,

The attribute name is class and not type. Yet another implicit vote to change it to use type and not class. :)

Use the following instead

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE objects PUBLIC "-//SPRING//DTD OBJECT//EN" "http://www.springframework.net/dtd/spring-objects.dtd">
<objects>
<object id="userData" class="CDICommon.Model.Security.UserData, CDICommon"/>
</objects>


The DTD declaration will now help in showing a better error message...



0 [456] INFO Spring.Objects.Factory.Support.AbstractObjectDefin itionReader - Loading XML object definitions from URL [C:/temp/projectPlugin.xml]
Spring.Objects.Factory.ObjectDefinitionStoreExcept ion: XmlException parsing XML document from URL [C:/temp/projectPlugin.xml] ---> System.Xml.XmlException: The 'type' attribute is not declared. An error occurred at , (5, 43). ---> System.Xml.Schema.XmlSchemaException: The 'type' attribute is not declared. An error occurred at , (5, 43).
at System.Xml.Schema.SchemaInfo.GetAttribute(SchemaEl ementDecl ed, XmlQualifiedName qname, Boolean& skip)
at System.Xml.Schema.Validator.ProcessElement()
--- End of inner exception stack trace ---

etc...



FYI, the latest dtd/xsd are available on the web. (They are also in the distribution)

http://www.springframework.net/dtd/spring-objects.dtd
and
http://www.springframework.net/xsd/spring-objects.xsd

Hope this helps you get started!

Cheers,
Mark