let schematron use hapi-fhir-base classloader (#4366)

This commit is contained in:
William Denton 2023-05-26 16:05:16 -07:00 committed by GitHub
parent a04a49cb68
commit f8548c5d7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -33,6 +33,8 @@ import ca.uhn.fhir.validation.SingleValidationMessage;
import ca.uhn.fhir.validation.ValidationContext;
import com.helger.commons.error.IError;
import com.helger.commons.error.list.IErrorList;
import com.helger.commons.io.resource.ClassPathResource;
import com.helger.commons.io.resource.IReadableResource;
import com.helger.schematron.ISchematronResource;
import com.helger.schematron.SchematronHelper;
import com.helger.schematron.svrl.jaxb.SchematronOutputType;
@ -149,7 +151,11 @@ public class SchematronBaseValidator implements IValidatorModule {
ourLog.error("Failed to close stream", e);
}
retVal = SchematronResourceSCH.fromClassPath(pathToBase);
// Allow Schematron to load SCH files from the 'validation-resources'
// bundles when running in an OSGi container. This is because the
// Schematron bundle does not have DynamicImport-Package in its manifest.
IReadableResource schResource = new ClassPathResource(pathToBase, this.getClass().getClassLoader());
retVal = new SchematronResourceSCH(schResource);
myClassToSchematron.put(theClass, retVal);
return retVal;
}