Results 1 to 3 of 3

Thread: Merging maps in xml file for parent-child beans

  1. #1
    Join Date
    Jun 2007
    Posts
    6

    Default Merging maps in xml file for parent-child beans

    G'day!

    I'm trying to merge my maps in Spring. However, I'm coming across a problem with it.

    So, here's the code (and yes, I'm using Spring 2.0):

    Code:
    <bean id="parent-bean" abstract="true">
    		<property name="mapValues">
    	      	<map>
    	      		<entry key="key">
    	      			<value>value</value>
    	      		</entry>
    	      	</map>
          </property>
    </bean>
    
    <bean id="child-bean" parent="parent-bean" class="some.class.here">
    		<property name="mapValues">
    	      	<map merge="true">
    	      		<entry key="key2">
    	      			<value>value2</value>
    	      		</entry>
    	      	</map>
          </property>
    </bean>
    Now, the problem is that at startup, I get this error:

    Code:
    org.springframework.beans.factory.BeanDefinitionStoreException: Line XXX in XML document from ServletContext
    resource [/WEB-INF/spring-config/config-name.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Attribute "merge" must be declared for element type "map".
    Caused by:
    org.xml.sax.SAXParseException: Attribute "merge" must be declared for element type "map".
    Where, Line XXX is listed every time I have a merge=true definition. I can't see the problem - can anyone else?

    Thanks,
    Andrew

  2. #2
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    That's probably an issue of the doctype declaration in your file. You probably still reference the spring-beans.dtd instead of the spring-beans-2.0.dtd.

    Jörg

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    If you are going to change this, it might be worth going for it and using XML schema instead.
    http://www.springframework.org/docs/...-configuration
    Last edited by karldmoore; Aug 27th, 2007 at 03:32 PM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •