Announcement Announcement Module
Collapse
No announcement yet.
SAXParseException in Application Context XML Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SAXParseException in Application Context XML

    I am trying to implement the AbstractRoutingDataSource and have constructed a DataSource with a map element. When I try it out I get the following exception:

    Code:
    org.xml.sax.SAXParseException: Attribute "key-type" must be declared for element type "map".
    I can't make sense of this. The type map does have a key-type, as you can see in my xmlcode below.

    Code:
    <bean id="dataSource" class="no.bbs.bkad.testklient.online.datasource.RoutingDataSource">
            <property name="targetDataSources">
                <map key-type="no.bbs.bkad.testklient.online.datasource.EnvironmentType">
                  <entry key="PP2" value-ref="dataSourcePP2"/>
                  <entry key="PP3" value-ref="dataSourcePP3"/>
                  <entry key="PP4" value-ref="dataSourcePP4"/>
                  <entry key="ST1" value-ref="dataSourceST1"/>
                  <entry key="ST2" value-ref="dataSourceST2"/>
                  <entry key="ST3" value-ref="dataSourceST3"/>
                  <entry key="ST4" value-ref="dataSourceST4"/>
                </map>
            </property>
            <property name="defaultTargetDataSource" value="dataSourcePP1"></property>
        </bean>

  • #2
    Hi DJViking

    This might be a dumb question (I am the master of them), but might as well get the easy one out of the way: are you referencing the correct DTD/schema?

    The spring-beans.dtd (for Spring 1.0, 1.1, 1.2, 2.0, and 2.1) uses this DTD declaration and does not expose the attribute.

    Code:
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    		"http://www.springframework.org/dtd/spring-beans.dtd">
    However, the Spring 2.0 and 2.1 DTD (spring-beans-2.0.dtd) does.

    Code:
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
    		  "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    So which one is at the top of your file? (If you are using the XML Schema version then that has alway had the relevant attribute.)

    If it's not this, then darn... I'll let someone smarter than me in the community reply

    Cheers
    Rick

    Comment


    • #3
      I use the following on top of the application context file.

      <?xml version="1.0" enconding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

      Comment


      • #4
        Originally posted by DJViking View Post
        I use the following on top of the application context file.

        <?xml version="1.0" enconding="UTF-8"?>
        <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
        Yes, this is Spring 1.x compatible DTD and it does not know attribute that you strive to use, as it is available starting from Spring 2.x.

        If you really use Spring 1.x then forgot about this attribute, if Spring 2.x - then change the refrred DTD in the header your context file, or even better, switch to schema-based context (as well just replace header).
        See Spring reference manual for details.

        Comment

        Working...
        X