Uploaded image for project: 'Hibernate Validator'
  1. Hibernate Validator
  2. HV-1007

Unable to parse validation.xml with IBM JDK

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 5.1.3.Final
    • Fix Version/s: 5.2.1.Final
    • Component/s: engine
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      HV can't read validation.xml on IBM JDK, causing a failure during creation of a ValidatorFactory - the failure:

      Exception in thread "main" javax.validation.ValidationException: HV000123: Unable to parse META-INF/validation.xml.
      	at org.hibernate.validator.internal.xml.XmlParserHelper.getSchemaVersion(XmlParserHelper.java:112)
      	at org.hibernate.validator.internal.xml.ValidationXmlParser.parseValidationXml(ValidationXmlParser.java:79)
      	at org.hibernate.validator.internal.engine.ConfigurationImpl.getBootstrapConfiguration(ConfigurationImpl.java:287)
      	at org.hibernate.validator.internal.engine.ConfigurationImpl.parseValidationXml(ConfigurationImpl.java:361)
      	at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:214)
      	at org.jboss.as.ee.beanvalidation.TestingApp.main(TestingApp.java:25)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
      	at java.lang.reflect.Method.invoke(Method.java:495)
      	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
      Caused by: java.io.IOException: Stream closed
      	at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:181)
      	at java.io.BufferedInputStream.reset(BufferedInputStream.java:457)
      	at org.hibernate.validator.internal.xml.XmlParserHelper.getSchemaVersion(XmlParserHelper.java:109)
      	... 10 more
      

      It looks like this is because XmlParserHelper (line 109) calls reset() on a xmlInputStream which was used for creating a XMLEventReader earlier - and for some reason, IBM JDK behaves in a way that it closes the input stream when creating a XMLEventReader out of it. So calling reset() ends with an IOException.

      How to reproduce - have any validation.xml on the classpath and run this code on IBM JDK:

      ValidatorFactory factory = Validation.byProvider(HibernateValidator.class).configure().buildValidatorFactory();
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: