6 Replies Latest reply on Nov 25, 2015 2:26 AM by Martin Kouba

    WELD and HibernateValidator - ConstraintViolations always reported as "text/plain".

    Chris Rankin Novice

      Hi,

       

      I am running WELD 2.3.1.Final inside Tomcat 8, along with RESTeasy 3.0.13.Final and Hibernate Validator 5.1.3.Final, and I have discovered that constraint violations from Hibernate Validator are always being reported as MIME type "text/plain". My understanding of Hibernate Validator is that the ValidationReport is supposed to be returned as JSON if the HTTP Accept request header is set to "application/json".

       

      I have created two example projects; one with WELD, RESTeasy and Hibernate Validator, and the other with just RESTeasy and Hibernate Validator. Only the project containing WELD has the buggy behaviour, which makes me suspect that there is a problem with the WELD + RESTeasy integration. (Both projects contain an Arquillian test that violates the same Hibernate Validator constraint).

       

      Could I have missed something when adding Hibernate Validator to the project, please? I have added both the resteasy-cdi and hibernate-validator-cdi "bridging" artifacts to the WAR, and validation is happening... but I really would prefer the constraint violations to be reported as JSON. Upgrading to Hibernate Validator 5.2.2.Final makes no difference either.

       

      There is also this log message:

      2015-11-23 21:33:54,298 INFO localhost-startStop-1 i18n - RESTEASY008550: Unable to find CDI supporting ValidatorFactory. Using default ValidatorFactory

      but I can't find any way of resolving this. (Having said that, it's not even considered to be warning).

       

      Thanks for any assistance here; is this a bug please?

      Cheers,

      Chris