Spring bean validation rule for constructor args erroneous

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #515198 Reply

    Robert Varga

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


    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):

    <?xml version="1.0" encoding="UTF-8"?>
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
        <!-- This is an abstract bean, the constructor argument count validator should not report a problem, but it does -->
        <bean id="abstractParent" class="java.util.Date" abstract="true">
            <constructor-arg index="0" value="1" />
            <constructor-arg index="1" value="1" />
        <bean id="concreteBean" parent="abstractParent">
            <constructor-arg index="2" value="1" />

    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 7 years, 3 months ago by Robert Varga.
    • This topic was modified 7 years, 3 months ago by Robert Varga.
    #515423 Reply



    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

    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:


    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



    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

You must be logged in to post in the forum log in