Results 1 to 4 of 4

Thread: Abstract bean - DTD problem?

  1. #1
    Join Date
    Aug 2004
    Posts
    123

    Default Abstract bean - DTD problem?

    I've looed through the forum and not really seen a definitive answer to this one. It's a bit of a puzzle. I have the following in my applicationContext.xml file, to declare an abstract bean which I can inherit from:

    <bean id="baseDAO" abstract="true">
    <property name="sessionFactory">
    <ref local="sessionFactory"/>
    </property>
    </bean>

    At the top of the file, there's the usual:

    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    Now, when I check the file for validity with JEdit, there's no problem. However, when I try to run a unit test with JUnit, I get the error which has been reported here before, and the test fails:

    org.xml.sax.SAXParseException: Attribute "abstract" must be declared for element type "bean".

    Why would this be occurring? Is there some way an obsolete DTD could be being used by JUnit, in which case where is it likely to be?

  2. #2
    Join Date
    Aug 2004
    Location
    Toulouse, France
    Posts
    148

    Default

    Eventually, the problem may come from the entity resolver which uses the .dtd bundled with spring.jar. Can you check which version of spring*.jar you have and if there's any old .dtd which could reside in your classpath ?

    Olivier

  3. #3
    Join Date
    Aug 2004
    Posts
    123

    Default

    Yes, well spotted! In fact, what seems to have happened is that my Maven project.xml file contained a dependency for an older version of Spring, from which I assume it was taking the DTD. I'm still surprised it would take precedence over the DTD explicitly pointed to in the DOCTYPE declaration.

    Haven't confirmed this yet but I'll report back when I do.

  4. #4
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Quote Originally Posted by jonmor
    Yes, well spotted! In fact, what seems to have happened is that my Maven project.xml file contained a dependency for an older version of Spring, from which I assume it was taking the DTD. I'm still surprised it would take precedence over the DTD explicitly pointed to in the DOCTYPE declaration.

    Haven't confirmed this yet but I'll report back when I do.
    The entity resolver maps the http url location to a local classpath version. So the older classpath version will end up being used. The whole point is not to go to the net unless it can't be found locally.

    Now I've always been a proponent of versioning the dtd's, but there's never quite been enough agreement on this to go ahead and do it.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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