Spring bean validation rule for constructor args erroneous

This topic contains 3 replies, has 2 voices, and was last updated by  support-tony 1 year, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #515198 Reply

    Robert Varga
    Participant

    The Spring bean validation rule for constructor arguments erroneously validates abstract bean definitions.

    Reproduce:

    1. Create a new Java project with any Java runtime.
    2. Add Spring facet, I tried this both with Spring facet versions 3.0, 3.1 and 4.1. A default project is sufficient.
    3. Add the following bean definitions into the applicationContext.xml or whatever you named the application context file (obviously correct the schema version to match your facet version for having a pristine test, although it matters not):

    4. Save the file.

    Now Spring validation is going to complain about the abstractParent bean having no 2-arg constructor, even though its bean definition is abstract and it should not validate abstract bean definitions.

    The concreteBean bean correctly will not have a problem since it has a 3rd constructor argument and a 3-argument constructor does exist.

    • This topic was modified 1 year, 2 months ago by  Robert Varga.
    • This topic was modified 1 year, 2 months ago by  Robert Varga.
    #515423 Reply

    support-tony
    Keymaster

    Robert,

    Thanks for the steps to reproduce the problem. I have raised a fault report for development to investigate.

    Does this false validation error affect any other functions that you’re using?

    To eliminate this false validation, you can turn off constructor argument validation. Go to Window->Preferences->Validation->Spring, open the Beans Validator node and turn off the Bean Constructor Argument Rule option, then click OK. This can also be done on a per-project basis.

    We’ll let you know when there is a fix for this.

    #515433 Reply

    Robert Varga
    Participant

    Hi Tony,

    I don’t think it affects any other functions, it is simply that the validator does not skip abstract beans.

    I raised the same issue in the Spring Tool Suite issue tracker, too:

    https://issuetracker.springsource.com/browse/STS-4435

    Unfortunately the suggested workaround disables this rule altogether so in order to eliminate false positives, it also eliminates valid positives (complaining about non-abstract beans not having constructors of the specified argument number).

    #515578 Reply

    support-tony
    Keymaster

    Robert,

    Thanks for raising the bug with STS. As some of the tools in our Spring support is based on STS, it may take a fix from those guys to fix it in MyEclipse though we may be able to fix this ourselves.

    You’re right that the workaround isn’t an acceptable workaround but, as far as I can tell, it’s the only way to avoid the spurious validation message. Fortunately, the problem doesn’t affect other functions but I can appreciate that it is annoying and confusing. Hopefully, we can do something about this before too long.

    Sorry, again, for the problem.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Spring bean validation rule for constructor args erroneous