Example usage for org.hibernate.internal.util.xml ErrorLogger ErrorLogger

List of usage examples for org.hibernate.internal.util.xml ErrorLogger ErrorLogger

Introduction

In this page you can find the example usage for org.hibernate.internal.util.xml ErrorLogger ErrorLogger.

Prototype

public ErrorLogger(String file) 

Source Link

Usage

From source file:org.beangle.orm.hibernate.internal.OverrideConfiguration.java

License:Open Source License

/**
 * Just disable xml file validation./*from   www .j a v  a2  s.  c  o m*/
 */
@Override
protected Configuration doConfigure(InputStream stream, String resourceName) throws HibernateException {
    try {
        ErrorLogger errorLogger = new ErrorLogger(resourceName);
        SAXReader reader = xmlHelper.createSAXReader(errorLogger, getEntityResolver());
        reader.setValidation(false);
        Document document = reader.read(new InputSource(stream));
        if (errorLogger.hasErrors()) {
            throw new MappingException("invalid configuration", errorLogger.getErrors().get(0));
        }
        doConfigure(document);
    } catch (DocumentException e) {
        throw new HibernateException("Could not parse configuration: " + resourceName, e);
    } finally {
        try {
            stream.close();
        } catch (IOException ioe) {
            logger.error("Could not close input stream for {}", resourceName);
        }
    }
    return this;
}