Announcement Announcement Module
No announcement yet.
Spring Validation and Constructors Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Validation and Constructors

    I noticed that a recent checkout of the Spring PetClinic Samples application has an error in STS, specifically it complains in the Spring validation on line 72 of applicationContext-hibernate.xml that clinic bean, of type org.springframework.samples.petclniic.hibernate.Hi bernateClinic does not have a constructor with 0 arguments. In fact, that file has no constructors. Amazingly enough, STS will 'quick fix' this and add a stub constructor that removes the error and allows the project to run without problems.

    I haven't noticed on prior versions of STS -- perhaps the Validator logic doesn't think java.lang.Objecte's empty constructor counts?

    Platform is Ubuntu 9.10, Java 1.6.0_16-b01, STS 2.3.0.RELEASE, check out of petclinic as of 1am 12-30-09.

  • #2

    In order to make sure I'll use the same PetClinic as you, can you post the SVN URL you are using to generate this issue?

    Thanks in advance.



    • #3
      The URL is:

      The version of the file is 175, last updated by 'cleau' on Wed Nov 25 13:45:52 EST 2009.


      • #4
        Thanks for providing the details.

        You are seeing the same error as reported in the following JIRA:

        IDE-1042: @Autowired-constructor not recognized correctly

        In my version of petclinic the HibernateClinic implementation has the following constructor:
        public HibernateClinic(SessionFactory sessionFactory) {
        	this.sessionFactory = sessionFactory;
        This constructor is not detected by the validation logic.



        • #5
          Ah for some reason missed seeing that constructor while I was paging through the file. Nevertheless, the spring valdiator misses it on mine as well.