Announcement Announcement Module
Collapse
No announcement yet.
Ant task to validate applicationContext.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ant task to validate applicationContext.xml

    Hi,

    Any support on the Ant tasks doing validation of applicationContext.xml ?

  • #2
    Amit,

    currently an ANT task which validates Spring beans config files is not planned.

    But it can be done. All the code for the validation itself is already available in the core plugin. But this code leverages the project management stuff (config XML file ".springBeansProject") provided by the Eclipse plugin. The file and it's settings (list of config files and config sets) is maintained by the project properties dialog.

    If anybody has the time to investigate further...

    Regards,
    Torsten

    Comment


    • #3
      Ant validation of bean definitions?

      If by validate one means 'XML validation', then Ant should be able to do this easily (?) using the Spring DTD.

      On my project I wrote an Ant target that validates an XML MVC definition file using XSD (I used BeanShell in Ant), so anything is possible.

      J. Betancourt

      Comment


      • #4
        Re: Ant validation of bean definitions?

        Originally posted by jbetancourt
        If by validate one means 'XML validation', then Ant should be able to do this easily (?) using the Spring DTD.
        Yes, DTD validation is the easy part.

        Creating the entire BeanDefinitionRegistry from a single application context and validating it's (inner and outer) bean classes with their properties + constructor arguments + parent bean is the fun part. Doing this for a hierachy of application contexts (with additional checking for bean overrides) is more fun ;-).

        Regards,
        Torsten

        Comment


        • #5
          I actually took a look at doing an ANT validator based on Torsten's code, essentially ripping out the Eclipse dependencies, which would not be very significant for that part of the codebase.

          The problem is that at the time (about a month ago), the Spring-IDE code was (and I believe still is) behind the current Spring version, so I put this off until such a time as

          a) the two are in sync, and
          b) I have some time :-)

          Regards,

          Comment


          • #6
            Hi,

            Rite now i was trying to do xmlvalidaion using spring dtd.
            Following is the target i was using.

            <target name="xmlvalidate" description="Generates a report of code convention violations.">
            <xmlvalidate failonerror="yes" warn="yes">
            <fileset dir="${web.dir}/WEB-INF" includes="applicationContext.xml"/>
            <xmlcatalog>
            <dtd
            publicId="-//SPRING//DTD BEAN//EN"
            location="http://www.springframework.org/dtd/spring-beans.dtd"/>
            </xmlcatalog>
            </xmlvalidate>
            </target>

            And the result is:

            BUILD FAILED
            file:E:/eclipse_workspace/windows_2.1_M4/<project>/build/build.xml:109: Could not validate document E:\eclipse_workspace\windows_2.1_M4\<project>\buil d\<project>\WEB-INF\applicationContext.xml

            Any Idea wht could be the problem here? How could i get where is the problem or more verbose output ?

            Regards,

            Comment


            • #7
              Hi,

              That worked when i changed the location to local directory.
              Probably now shld have a look at the Eclipse IDE code

              Thanks,

              Comment


              • #8
                Hi,

                That worked when i changed the location to local directory.
                Probably now shld have a look at the Eclipse IDE code

                Thanks,

                Comment


                • #9
                  Test vs. Production XML Validation

                  I'm concerned about maintaining the 2 xml files as our system grows. If I rename classes or add dependencies for example, I can easily work the kinks out of the spring-test.xml, but is there a way for me to "validate" the production spring.xml without waiting for runtime exceptions?

                  And I'm referring to Torsten's more complex definition of validate here.

                  I haven't yet tried out the Eclipse plugin, so is that the way to go?

                  .rob.park.

                  Comment


                  • #10
                    Is there any plan to support validation via ant?

                    dino

                    Comment


                    • #11
                      Still depends what you mean by validate

                      You could easily create a task to simply load the context files as a BeanFactory and verify no dependency errors for example. Alternatively use the beandoc ant task to documet/graph the context, though that would need manual validation by reading the output docs.

                      Regards,

                      Comment


                      • #12
                        Originally posted by davison
                        Still depends what you mean by validate

                        You could easily create a task to simply load the context files as a BeanFactory and verify no dependency errors for example. Alternatively use the beandoc ant task to documet/graph the context, though that would need manual validation by reading the output docs.

                        Regards,
                        Just implement what the eclipse plug-in does. It would be nice if the actual validation logic was moved from the eclipse project into another project. THEN write tools on top of it (e.g. ant, eclipse, idea etc).

                        Dino

                        Comment

                        Working...
                        X