<div dir="ltr">My bad, I mixed the validation.xml and constraints.xml files (and mixed the XSDs). This is what I done and it works (with version 1.1 everywhere) :<div><br></div><div><br></div><div style><b>validation.xml</b></div>
<div style><div><font face="courier new, monospace">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</font></div><div><font face="courier new, monospace">&lt;validation-config</font></div><div><font face="courier new, monospace">        xmlns=&quot;<a href="http://jboss.org/xml/ns/javax/validation/configuration">http://jboss.org/xml/ns/javax/validation/configuration</a>&quot;</font></div>
<div><font face="courier new, monospace">        xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>&quot;</font></div><div><font face="courier new, monospace">        xsi:schemaLocation=&quot;<a href="http://jboss.org/xml/ns/javax/validation/configuration">http://jboss.org/xml/ns/javax/validation/configuration</a> validation-configuration-1.1.xsd&quot;</font></div>
<div><font face="courier new, monospace">        version=&quot;1.1&quot;&gt;</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">  &lt;constraint-mapping&gt;META-INF/constraints.xml&lt;/constraint-mapping&gt;</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">&lt;/validation-config&gt;</font></div><div><br></div><div style><b>constraints.xml</b></div><div style><div><font face="courier new, monospace">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</font></div>
<div><font face="courier new, monospace">&lt;constraint-mappings</font></div><div><font face="courier new, monospace">        xmlns=&quot;<a href="http://jboss.org/xml/ns/javax/validation/mapping">http://jboss.org/xml/ns/javax/validation/mapping</a>&quot;</font></div>
<div><font face="courier new, monospace">        xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>&quot;</font></div><div><font face="courier new, monospace">        xsi:schemaLocation=&quot;<a href="http://jboss.org/xml/ns/javax/validation/mapping">http://jboss.org/xml/ns/javax/validation/mapping</a> validation-mapping-1.1.xsd&quot;</font></div>
<div><font face="courier new, monospace">        version=&quot;1.1&quot;&gt;</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">  &lt;bean class=&quot;org.agoncal.book.javaee7.chapter03.ex14.Book14&quot; ignore-annotations=&quot;false&quot;&gt;</font></div>
<div><font face="courier new, monospace">    &lt;field name=&quot;title&quot;&gt;</font></div><div><font face="courier new, monospace">      &lt;constraint annotation=&quot;javax.validation.constraints.NotNull&quot;/&gt;</font></div>
<div><font face="courier new, monospace">    &lt;/field&gt;</font></div><div><font face="courier new, monospace">    &lt;field name=&quot;price&quot;&gt;</font></div><div><font face="courier new, monospace">      &lt;constraint annotation=&quot;javax.validation.constraints.NotNull&quot;/&gt;</font></div>
<div><font face="courier new, monospace">      &lt;constraint annotation=&quot;javax.validation.constraints.Min&quot;&gt;</font></div><div><font face="courier new, monospace">        &lt;element name=&quot;value&quot;&gt;2&lt;/element&gt;</font></div>
<div><font face="courier new, monospace">      &lt;/constraint&gt;</font></div><div><font face="courier new, monospace">    &lt;/field&gt;</font></div><div><font face="courier new, monospace">    &lt;field name=&quot;description&quot;&gt;</font></div>
<div><font face="courier new, monospace">      &lt;constraint annotation=&quot;javax.validation.constraints.Size&quot;&gt;</font></div><div><font face="courier new, monospace">        &lt;element name=&quot;max&quot;&gt;2000&lt;/element&gt;</font></div>
<div><font face="courier new, monospace">      &lt;/constraint&gt;</font></div><div><font face="courier new, monospace">    &lt;/field&gt;</font></div><div><font face="courier new, monospace">  &lt;/bean&gt;</font></div><div>
<font face="courier new, monospace">&lt;/constraint-mappings&gt;</font></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/2 Emmanuel Bernard <span dir="ltr">&lt;<a href="mailto:emmanuel@hibernate.org" target="_blank">emmanuel@hibernate.org</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It looks like you forgot a space in your xsi:schemaLocation<br>
<br>
    xsi:schemaLocation=&quot;<a href="http://jboss.org/xml/ns/javax/validation/mappingvalidation-mapping-1.1.xsd" target="_blank">http://jboss.org/xml/ns/javax/validation/mappingvalidation-mapping-1.1.xsd</a>&quot;<br>
    -&gt;<br>
    xsi:schemaLocation=&quot;<a href="http://jboss.org/xml/ns/javax/validation/mapping" target="_blank">http://jboss.org/xml/ns/javax/validation/mapping</a> validation-mapping-1.0.xsd&quot;<br>
<br>
But that raises an interesting question. Today we have added a version<br>
number in validation.xml and I believe the behavior is well defined.<br>
What about mapping files? I don&#39;t think we considered that yet. What<br>
should we do. Throwing a few ideas:<br>
<br>
- add a version number like we did for validation.xml<br>
- enforce consistent version use between validation.xml and the<br>
  contained mapping files<br>
<br>
Thoughts?<br>
<br>
Emmanuel<br>
<div><div class="h5"><br>
On Wed 2013-01-02 16:38, Antonio Goncalves wrote:<br>
&gt; Hi all,<br>
&gt;<br>
&gt; I&#39;m trying to use validation.xml 1.1 to add constraints to me beans but I<br>
&gt; get a ValidationException. Here is the validation.xml file :<br>
&gt;<br>
&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>
&gt; &lt;constraint-mappings<br>
&gt;         xmlns=&quot;<a href="http://jboss.org/xml/ns/javax/validation/mapping" target="_blank">http://jboss.org/xml/ns/javax/validation/mapping</a>&quot;<br>
&gt;         xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>
&gt;         xsi:schemaLocation=&quot;<a href="http://jboss.org/xml/ns/javax/validation/mappingvalidation-mapping-1.1.xsd" target="_blank">http://jboss.org/xml/ns/javax/validation/mappingvalidation-mapping-1.1.xsd</a>&quot;<br>

&gt;         version=&quot;1.1&quot;&gt;<br>
&gt;<br>
&gt;   &lt;default-package&gt;org.agoncal.book.javaee7.chapter03&lt;/default-package&gt;<br>
&gt;   &lt;bean class=&quot;ex14.Book&quot; ignore-annotations=&quot;false&quot;&gt;<br>
&gt;     &lt;field name=&quot;title&quot;&gt;<br>
&gt;       &lt;constraint annotation=&quot;javax.validation.constraints.NotNull&quot;/&gt;<br>
&gt;     &lt;/field&gt;<br>
&gt;     &lt;field name=&quot;price&quot;&gt;<br>
&gt;       &lt;constraint annotation=&quot;javax.validation.constraints.NotNull&quot;/&gt;<br>
&gt;       &lt;constraint annotation=&quot;javax.validation.constraints.Min&quot;&gt;<br>
&gt;         &lt;element name=&quot;min&quot;&gt;2&lt;/element&gt;<br>
&gt;       &lt;/constraint&gt;<br>
&gt;     &lt;/field&gt;<br>
&gt;   &lt;/bean&gt;<br>
&gt; &lt;/constraint-mappings&gt;<br>
&gt;<br>
&gt; In the spec (§8.1.4. XML Schema) it mentions something about versions, so<br>
&gt; I&#39;ve tried to change my schema to 1.0 but still get my exception. Here is<br>
&gt; the part of the spec that talks about version issues and the stack trace.<br>
&gt;<br>
&gt; Any idea ?<br>
&gt; Thanks<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --------------------------------------------<br>
&gt; Stacktrace<br>
&gt; 8.1.4. XML Schema<br>
&gt;<br>
&gt; This section contains the XML schema used for constraint mapping<br>
&gt; descriptors.<br>
&gt;<br>
&gt; &gt;From Bean Validation revision 1.1 onwards, mapping authors must specify the<br>
&gt; used version of the schema within the version attribute of the<br>
&gt; constraint-mappings element. Implementations supporting Bean Validation 1.1<br>
&gt; must properly parse mapping descriptors of Bean Validation 1.0 and 1.1. If<br>
&gt; the version attribute attribute is not given, schema version 1.0 is to be<br>
&gt; assumed by the Bean Validation Provider.<br>
&gt;<br>
&gt; In case an unknown version is given (e.g. if a mapping descriptor adhering<br>
&gt; to a future schema version is parsed by a Bean Validation 1.1 provider) a<br>
&gt; ValidationException is raised.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --------------------------------------------<br>
&gt; Stacktrace<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; javax.validation.ValidationException: HV000100: Unable to parse<br>
&gt; META-INF/validation.xml.<br>
&gt; at<br>
&gt; org.hibernate.validator.internal.xml.ValidationXmlParser.unmarshal(ValidationXmlParser.java:121)<br>
&gt; at<br>
&gt; org.hibernate.validator.internal.xml.ValidationXmlParser.parseValidationXml(ValidationXmlParser.java:77)<br>
&gt; at<br>
&gt; org.hibernate.validator.internal.engine.ConfigurationImpl.getBootstrapConfiguration(ConfigurationImpl.java:263)<br>
&gt; at<br>
&gt; org.hibernate.validator.internal.engine.ConfigurationImpl.parseValidationXml(ConfigurationImpl.java:328)<br>
&gt; at<br>
&gt; org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:195)<br>
&gt; at<br>
&gt; javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:107)<br>
&gt; at<br>
&gt; org.agoncal.book.javaee7.chapter03.ex14.Book14Test.init(Book14Test.java:36)<br>
&gt; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
&gt; at<br>
&gt; sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br>
&gt; at<br>
&gt; sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>
&gt; at<br>
&gt; org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)<br>
&gt; at<br>
&gt; org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)<br>
&gt; at<br>
&gt; org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)<br>
&gt; at<br>
&gt; org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)<br>
&gt; at org.junit.runners.ParentRunner.run(ParentRunner.java:309)<br>
&gt; at org.junit.runner.JUnitCore.run(JUnitCore.java:160)<br>
&gt; at<br>
&gt; com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)<br>
&gt; at<br>
&gt; com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)<br>
&gt; at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)<br>
&gt; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
&gt; at<br>
&gt; sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br>
&gt; at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)<br>
&gt; Caused by: javax.xml.bind.UnmarshalException<br>
&gt;  - with linked exception:<br>
&gt; [org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 22; cvc-elt.1<br>
&gt; : Déclaration de l&#39;élément &#39;constraint-mappings&#39; introuvable.]<br>
&gt; at<br>
&gt; javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:335)<br>
&gt; at<br>
&gt; com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:512)<br>
&gt; at<br>
&gt; com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:209)<br>
&gt; at<br>
&gt; com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:181)<br>
&gt; at<br>
&gt; com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:235)<br>
&gt; at<br>
&gt; org.hibernate.validator.internal.xml.ValidationXmlParser.unmarshal(ValidationXmlParser.java:117)<br>
&gt; ... 24 more<br>
&gt; Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 22;<br>
&gt; cvc-elt.1 : Déclaration de l&#39;élément &#39;constraint-mappings&#39; introuvable.<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1901)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:741)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:565)<br>
&gt; at<br>
&gt; com.sun.xml.internal.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:86)<br>
&gt; at<br>
&gt; com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:135)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:506)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:602)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3065)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:881)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)<br>
&gt; at<br>
&gt; com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)<br>
&gt; at<br>
&gt; com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:203)<br>
&gt; ... 27 more<br>
&gt;<br>
&gt; janv. 02, 2013 4:23:09 PM org.hibernate.validator.internal.util.Version<br>
&gt; &lt;clinit&gt;<br>
&gt; INFO: HV000001: Hibernate Validator 5.0.0.Alpha2<br>
&gt; janv. 02, 2013 4:23:09 PM<br>
&gt; org.hibernate.validator.internal.xml.ValidationXmlParser unmarshal<br>
&gt; INFO: HV000007: META-INF/validation.xml found. Parsing XML based<br>
&gt; configuration.<br>
&gt;<br>
&gt; --<br>
&gt; Antonio Goncalves<br>
&gt; Software architect and Java Champion<br>
&gt;<br>
</div></div>&gt; Web site &lt;<a href="http://www.antoniogoncalves.org/" target="_blank">http://www.antoniogoncalves.org/</a>&gt; |<br>
&gt; Twitter&lt;<a href="http://twitter.com/agoncal" target="_blank">http://twitter.com/agoncal</a>&gt;<br>
&gt;  | LinkedIn &lt;<a href="http://www.linkedin.com/in/agoncal" target="_blank">http://www.linkedin.com/in/agoncal</a>&gt; | Paris<br>
&gt; JUG&lt;<a href="http://www.parisjug.org/" target="_blank">http://www.parisjug.org/</a>&gt;<br>
&gt;  | Devoxx France &lt;<a href="http://www.devoxx.fr/" target="_blank">http://www.devoxx.fr/</a>&gt;<br>
<br>
&gt; _______________________________________________<br>
&gt; beanvalidation-dev mailing list<br>
&gt; <a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
<br>
_______________________________________________<br>
beanvalidation-dev mailing list<br>
<a href="mailto:beanvalidation-dev@lists.jboss.org">beanvalidation-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/beanvalidation-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/beanvalidation-dev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Antonio Goncalves <br>Software architect and Java Champion<br><br><a href="http://www.antoniogoncalves.org/" target="_blank">Web site</a> | <a href="http://twitter.com/agoncal" target="_blank">Twitter</a> | <a href="http://www.linkedin.com/in/agoncal" target="_blank">LinkedIn</a> | <a href="http://www.parisjug.org/" target="_blank">Paris JUG</a> | <a href="http://www.devoxx.fr/" target="_blank">Devoxx France</a>
</div>