# Nondeterministic behavior of HibernateValidator (in springboot?) when both annotation and xml-based definition are used

**URL:** <https://discourse.hibernate.org/t/nondeterministic-behavior-of-hibernatevalidator-in-springboot-when-both-annotation-and-xml-based-definition-are-used/7679>\
**Category:** Hibernate Validator\
**Created:** [May 22, 2023, 1:24pm UTC](https://discourse.hibernate.org/t/nondeterministic-behavior-of-hibernatevalidator-in-springboot-when-both-annotation-and-xml-based-definition-are-used/7679 "2023-05-22T13:24:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alfonz19](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/alfonz19/32/2440_2.png) [@alfonz19](https://discourse.hibernate.org/u/alfonz19)\
**Post date:** [May 22, 2023, 1:24pm UTC](https://discourse.hibernate.org/t/nondeterministic-behavior-of-hibernatevalidator-in-springboot-when-both-annotation-and-xml-based-definition-are-used/7679/1 "2023-05-22T13:24:19Z")

</div>

MWE: [GitHub - alfonz19/validator-fail-mwe](https://github.com/alfonz19/validator-fail-mwe)

After fresh app start calling validation of annotated DTO will work as expected, and after that also validation of DTO having validation defined in validation-constraints.xml will work as expected. Everything works.

After fresh app start calling validation of DTO having validation defined in validation-constraints.xml will FAIL, and after that calling validation of annotated DTO will also FAIL. Now every validation FAILS.

Any idea? Any suggestion what to debug?

tested in springboot:

- 2.7.12
- 3.1.0

---

<div class="post-metadata">

**Author:** ![mbekhta](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mbekhta/32/2044_2.png) [@mbekhta](https://discourse.hibernate.org/u/mbekhta)\
**Post date:** [May 22, 2023, 4:53pm UTC](https://discourse.hibernate.org/t/nondeterministic-behavior-of-hibernatevalidator-in-springboot-when-both-annotation-and-xml-based-definition-are-used/7679/2 "2023-05-22T16:53:53Z")

</div>

Hey @alfonz19  
Thanks for reaching out and reporting the problem with a reproducer. I’ve replied to your JIRA ticket here - [[HV-1949] - Hibernate JIRA](https://hibernate.atlassian.net/browse/HV-1949?focusedCommentId=111661)

---

<div class="post-metadata">

**Author:** ![alfonz19](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/alfonz19/32/2440_2.png) [@alfonz19](https://discourse.hibernate.org/u/alfonz19)\
**Post date:** [May 23, 2023, 8:10am UTC](https://discourse.hibernate.org/t/nondeterministic-behavior-of-hibernatevalidator-in-springboot-when-both-annotation-and-xml-based-definition-are-used/7679/3 "2023-05-23T08:10:45Z")

</div>

Thanks, I was just trying multiple fora as I didn’t get any traction with that on SO, so I was just hoping to get some hint anywhere. Sorry about this spamming. Thanks for confirming bug and workarounds, I will test them. I will update SO questions to link to this issue if anyone will find this.

---

<div class="post-metadata">

**Author:** ![mbekhta](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/mbekhta/32/2044_2.png) [@mbekhta](https://discourse.hibernate.org/u/mbekhta)\
**Post date:** [May 23, 2023, 8:32am UTC](https://discourse.hibernate.org/t/nondeterministic-behavior-of-hibernatevalidator-in-springboot-when-both-annotation-and-xml-based-definition-are-used/7679/4 "2023-05-23T08:32:47Z")

</div>

hey no worries 😃  
It would be nice if you could confirm that the programmatic definition helps – I have tried that on a small test and it worked, but you have a bigger app so let’s hope there’s nothing else in there.

> [@alfonz19](#):
>
> I will update SO questions to link to this issue if anyone will find this.

Thanks, appreciate that!
