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