The JSR-303 bean validation framework provides the possibility to configure the validatation framework via XML.
E.g. META-INF/validation.xml
See chapter
4.4.6. XML Configuration: META-INF/validation.xml
of the spec for details: http://download.oracle.com/otndocs/jcp/bean_validation-1.0-fr-oth-JSpec/
4.4.6. XML Configuration: META-INF/validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<validation-config
xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd">
<default-provider>com.acme.ACMEProvider</default-provider>
<message-interpolator>com.acme.ACMEAwareMessageInterpolator</message-interpolator>
<constraint-mapping>META-INF/validation/order-constraints.xml</constraint-mapping>
<constraint-mapping>META-INF/validation/catalog-constraints.xml</constraint-mapping>
<constraint-mapping>META-INF/validation/customer-constraints.xml</constraint-mapping>
<property name="com.acme.validation.logging">WARN</property>
<property name="com.acme.validation.safetyChecking">failOnError</property>
</validation-config>
Package the xml file with your persistence jar (META-INF/validation.xml) and it should work.
Depending on your deployment packaging (e.g. EAR) it might be necessary to put it in a shared lib in the EAR's lib folder.
The hibernate documentation says:
The key to enable XML configuration for Hibernate Validator is the
file validation.xml. If this file exists in the classpath its
configuration will be applied when the ValidationFactory gets created.
Example 4.1, “validation-configuration-1.0.xsd” shows a model view of
the xsd valiation.xml has to adhere to.
http://docs.jboss.org/hibernate/validator/4.0.1/reference/en/html_single/#d0e1867