PDA

View Full Version : First time user blues... (configuration in web.xml error)


MikeC
07-18-2005, 08:34 PM
.NET neophyte here, and having a problem with a simple application. I'm sure it's my fault, but I've done a pretty thorough check...

I've copied the 3 files from the spring.net distribution (2 dll's, 1 xml) into a "lib" directory under my apps root dir, and added the 2 references in the project. VS.NET shows the XML well formed.

I'm at a loss; any help appreciated.



My error:
================================
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Exception in configuration section handler.

Source Error:


Line 10:
Line 11: <spring>
Line 12: <context type="Spring.Context.Support.XmlApplicationContext, Spring.Core">
Line 13: <resource uri="config://spring/objects"/>
Line 14: </context>


Source File: c:\inetpub\wwwroot\PdfServletTest\web.config Line: 12


--------------------------------------------------------------------------------


My 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 type="Spring.Context.Support.XmlApplicationContext, Spring.Core">
<resource uri="config://spring/objects"/>
</context>

<objects>
<object name="FilenameProvider"
type="PdfServletTest.FilenameProvider, PdfServletTest">
<property name="FileName">c:/downloads/onlisp.pdf</property>
</object>
</objects>

</spring>


<system.web>

... (generated stuff follows)

MikeC
07-19-2005, 05:25 PM
Solved. Well, I got it working; not sure if this is a "solution" as such.

I change the configuration in the spring part from:

<objects>
<object name="FilenameProvider"
type="PdfServletTest.FilenameProvider, PdfServletTest">
<property name="FileName">c:/downloads/onlisp.pdf</property>
</object>
</objects>

To (note value tags)

<objects>
<object name="FilenameProvider"
type="PdfServletTest.FilenameProvider, PdfServletTest">
<property name="FileName">
<value>c:/downloads/onlisp.pdf</value>
</property>
</object>
</objects>


And the confuration is able to be read.

Rick Evans
07-20-2005, 09:12 AM
Hi Mike

Yes that is the correct solution. The dtd (http://www.springframework.net/dtd/spring-objects.dtd) that is part of the current release should see you straight (there is no mixed content in the <property/> element).

The upcoming 1.0 release also supports a number of convenience attributes to make the authoring of one's object definitions easier. You can now express your object definition snippet like so...

<object name="FilenameProvider" type="PdfServletTest.FilenameProvider, PdfServletTest">
<property name="FileName" value="c:/downloads/onlisp.pdf"/>
</object>

I agree that the error message that was reported (by Spring.NET) is less than useful... apologies for that. A lot of work has been put into making Spring.NET report meaningful error messages, and this improved error reporting will be a part of the 1.0 release (incidentally, this release also moves away from DTD based validation to XML Schema based validation).

Ciao
Rick

MikeC
07-20-2005, 02:39 PM
Hi Mike

Yes that is the correct solution. The dtd (http://www.springframework.net/dtd/spring-objects.dtd) that is part of the current release should see you straight (there is no mixed content in the <property/> element).

Thanks Rick.

I'll download the DTD and keep that handy; I KNEW it was something simple (and my fault)!

Rick Evans
07-20-2005, 03:13 PM
Hi Mike

No worries... I still do this myself on occasion. If there's anything that you can think of that would have stopped you (and me) making this error in the first place, or that would stop anyone else making this typo in future, just bang on the 'Post Reply' button on this forum.

An IDE addin (for Visual Studio) would be nice... object property dropdowns, validation, autocompletion, object graph visualisations, the list is endless. I don't personally use any of the blocks from the Enterprise Library (http://msdn.microsoft.com/practices/default.aspx?pull=/library/en-us/dnpag2/html/entlib.asp) from Microsoft's Patterns & Practices group (http://msdn.microsoft.com/practices/), but the configuration GUI that ships with their January release (and the recent update) is really nice. We really must get something like that (I would prefer it as an addin myself) for Spring.NET.

On a slightly lower tech note, how about a crib sheet that just lists loads and loads of XML configuration snippets (provided as a standalone CHM formatted file and as Visual Studio integrated help)? The reference documentation demonstrates XML snippets for each supported configuration option, but these examples are spread pretty much over the whole chapter.

I'm thinking of snippets for plain objects, objects with properties, objects with ctor args, objects with ctor args that are inner object definitions, objects with both properties and ctor args, objects that are instantiated via a static factory method, objects that are instantiated via an instance factory method, objects with <null/>s, objects with string properties, objects with properties that need type conversion, objects that have lists as properties, objects that have sets as properties, objects that have dictionaries as properties, objects that have lists of lists as properties, objects that have sets of dictionaries as properties, objects that have dictionaries that map inner objects as keys to lists of primitives for values as properties... whew. Mandinga, that is a lot of configuration snippets.

Shucks, I love heaping work on my plate :?

Ciao
Rick

Aleks Seovic
08-13-2005, 02:17 PM
Go for it :) It would definitely help...