log.warn( "Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null." );
return;
}
XMLHelper xmlHelper = new XMLHelper();
List errors = new ArrayList();
SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() );
try {
saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
//saxReader.setFeature( "http://apache.org/xml/features/validation/dynamic", true );
//set the default schema locators
saxReader.setProperty( "http://apache.org/xml/properties/schema/external-schemaLocation",
"http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd");
}
catch (SAXException e) {
saxReader.setValidation( false );
}
for ( String xmlFile : xmlFiles ) {
InputStream resourceAsStream = newTempClassLoader.getResourceAsStream( xmlFile );
if (resourceAsStream == null) continue;
BufferedInputStream is = new BufferedInputStream( resourceAsStream );
try {
errors.clear();
org.dom4j.Document doc = saxReader.read( is );
if ( errors.size() != 0 ) {
throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
}
Element rootElement = doc.getRootElement();
if ( rootElement != null && "entity-mappings".equals( rootElement.getName() ) ) {