use of org.hibernate.internal.util.xml.XsdException in project hibernate-orm by hibernate.
the class PersistenceXmlParser method resolveLocalSchema.
private Schema resolveLocalSchema(String schemaName) {
// These XSD resources should be available on the Hibernate ClassLoader
final URL url = classLoaderService.locateResource(schemaName);
if (url == null) {
throw new XsdException("Unable to locate schema [" + schemaName + "] via classpath", schemaName);
}
try {
InputStream schemaStream = url.openStream();
try {
StreamSource source = new StreamSource(url.openStream());
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
return schemaFactory.newSchema(source);
} catch (SAXException e) {
throw new XsdException("Unable to load schema [" + schemaName + "]", e, schemaName);
} catch (IOException e) {
throw new XsdException("Unable to load schema [" + schemaName + "]", e, schemaName);
} finally {
try {
schemaStream.close();
} catch (IOException e) {
LOG.debugf("Problem closing schema stream [%s]", e.toString());
}
}
} catch (IOException e) {
throw new XsdException("Stream error handling schema url [" + url.toExternalForm() + "]", schemaName);
}
}
use of org.hibernate.internal.util.xml.XsdException in project hibernate-orm by hibernate.
the class JaxbCfgProcessor method resolveLocalSchema.
private Schema resolveLocalSchema(String schemaName, String schemaLanguage) {
URL url = classLoaderService.locateResource(schemaName);
if (url == null) {
throw new XsdException("Unable to locate schema [" + schemaName + "] via classpath", schemaName);
}
try {
InputStream schemaStream = url.openStream();
try {
StreamSource source = new StreamSource(url.openStream());
SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage);
return schemaFactory.newSchema(source);
} catch (SAXException e) {
throw new XsdException("Unable to load schema [" + schemaName + "]", e, schemaName);
} catch (IOException e) {
throw new XsdException("Unable to load schema [" + schemaName + "]", e, schemaName);
} finally {
try {
schemaStream.close();
} catch (IOException e) {
log.debugf("Problem closing schema stream [%s]", e.toString());
}
}
} catch (IOException e) {
throw new XsdException("Stream error handling schema url [" + url.toExternalForm() + "]", schemaName);
}
}
Aggregations