PDA

View Full Version : Error getting object



Anonymous
10-26-2004, 02:06 PM
Hi,

I'm trying out the Spring Framework and having some problems getting an object. Below is the code snippet I'm trying to execute and the configuration in my app.config. The error I'm getting is:
{"Error registering object with name 'ArtefactModule' defined in '[Configuration File Section] : objects' : Object class [zetcom.MuseumPlus.UIComponents.ArtefactModule, zetcom.MuseumPlus.UIComponents] not found." }
The assembly UIComponents is in the same directory as all other dll's (including spring's).

IApplicationContext appCtx = ConfigurationSettings.GetConfig("objects") as IApplicationContext;
m_module = (IMPModule)appCtx.GetObject(m_viewName + "Module");
m_layoutManager.LayoutModule(m_module);



<configSections>
<section name="objects" type="Spring.Context.Support.ApplicationContextHandler,S pring.Context"/>
</configSections>

<objects>
<object id="ArtefactModule" class="zetcom.MuseumPlus.UIComponents.ArtefactModule, zetcom.MuseumPlus.UIComponents"/>
</objects>

Thanks for any help
Michel

Rick Evans
10-26-2004, 03:25 PM
Hi

Is the name of the assembly that is sitting in the same directory as everything else actually called 'zetcom.MuseumPlus.UIComponents.dll' ? Or is it called simply 'UIComponents.dll' ?

If it is the latter case, then the XML snippet should read like so...


<objects>
<object id="ArtefactModule" class="zetcom.MuseumPlus.UIComponents.ArtefactModule,UICo mponents"/>
</objects>

Shucks, I sure hope that is the problem :D

Ciao
Rick

Anonymous
10-27-2004, 02:25 PM
Hi Rick,

Thanks, that solved the problem.
Another question: is it possible to get objects without the xml configuration eg. by providing the name/id and class properties directly to IApplicationContext? i will most likely have the config information in a db so i would like to read the information from the db.

Michel

Mark Pollack
10-27-2004, 06:18 PM
Hi, Michel

Glad that solved the issue. There is not yet an out of the box solution for getting object factory/application context configuration information out of the database. There are some prototypes in Spring.Java however. You can find some information on JIRA here http://opensource.atlassian.com/projects/spring/browse/SPR-95 , in particular the last two comments that link to some code.

Just curious, what are your requirements for db usage? Can you 'get-away' with file based configuration for now?

Cheers,
Mark

Anonymous
10-28-2004, 06:55 AM
Hi Mark,

Yes I can 'get away' with the file based configuration for now.
What I'm doing is reading the xml chunk used for Spring into a MemoryStream and passing this to the XMLObjectfactory (see code below). Would be nice though to have setters on the ObjectFactory to fill in the required information :). Even better, a 'DBOjectFactory' which could be mapped to a DB Table containing the config information :D. And the best would be, if additionally this DBObjectFactory could be instantiated through NHibernate... 8)

layoutReader.ReadLayoutConfiguration();
byte[] xmlString = Encoding.UTF8.GetBytes(layoutReader.FormTypeDefini tion);
MemoryStream xmlStream = new MemoryStream(xmlString);
XmlObjectFactory objFactory = new XmlObjectFactory(xmlStream);
form = objFactory.GetObject(layoutReader.FormType) as IMPForm;
form.FormHeight = layoutReader.FormHeight;
form.FormWidth = layoutReader.FormWidth;
Cheers
Michel