int endIndex = moduleXmlUrl.toExternalForm().lastIndexOf('/');
URL moduleUrl = new URL(moduleXmlUrl.toExternalForm().substring(0, endIndex));
logger.debug("Loading module '{}' for site '{}'", moduleXmlUrl, this);
// Load and validate the module descriptor
ValidationErrorHandler errorHandler = new ValidationErrorHandler(moduleXmlUrl);
docBuilder.setErrorHandler(errorHandler);
Document moduleXml = docBuilder.parse(moduleXmlUrl.openStream());
if (errorHandler.hasErrors()) {
logger.error("Errors found while validating module descriptor {}. Site '{}' is not loaded", moduleXml, this);
throw new IllegalStateException("Errors found while validating module descriptor " + moduleXml);
}
// We need the module id even if the module initialization fails to log