use of org.hibernate.boot.MappingException in project hibernate-orm by hibernate.
the class AbstractBinder method seekRootElementStartEvent.
protected StartElement seekRootElementStartEvent(XMLEventReader staxEventReader, Origin origin) {
XMLEvent rootElementStartEvent;
try {
rootElementStartEvent = staxEventReader.peek();
while (rootElementStartEvent != null && !rootElementStartEvent.isStartElement()) {
staxEventReader.nextEvent();
rootElementStartEvent = staxEventReader.peek();
}
} catch (Exception e) {
throw new MappingException("Error accessing stax stream", e, origin);
}
if (rootElementStartEvent == null) {
throw new MappingException("Could not locate root element", origin);
}
return rootElementStartEvent.asStartElement();
}
use of org.hibernate.boot.MappingException in project hibernate-orm by hibernate.
the class AbstractBinder method jaxb.
@SuppressWarnings("unchecked")
protected <T> T jaxb(XMLEventReader reader, Schema xsd, JAXBContext jaxbContext, Origin origin) {
final ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
try {
final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
if (isValidationEnabled()) {
unmarshaller.setSchema(xsd);
} else {
unmarshaller.setSchema(null);
}
unmarshaller.setEventHandler(handler);
return (T) unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new MappingException("Unable to perform unmarshalling at line number " + handler.getLineNumber() + " and column " + handler.getColumnNumber() + ". Message: " + handler.getMessage(), e, origin);
}
}
Aggregations