gematik / app-referencevalidator

The reference validator is a tool to perform advanced validation of FHIR resources for TI applications and interoperability standards
https://fachportal.gematik.de/hersteller-anbieter/primaersysteme/referenzvalidator
Other
22 stars 4 forks source link

Unnrecognized field "packageName #2

Closed joergreichert closed 2 years ago

joergreichert commented 2 years ago
de.gematik.refv.commons.exceptions.ValidationModuleInitializationException: Could not load module configuration

    at de.gematik.refv.valmodule.erp.ErpValidationModule.initialize(ErpValidationModule.java:69)
    at de.gematik.refv.ValidationModuleFactory.createValidationModule(ValidationModuleFactory.java:51)
...
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "packageName" (class de.gematik.refv.commons.configuration.PackageDefinitionByVersion), not marked as ignorable (one known property: "packageVersions"])
 at [Source: (sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream); line: 34, column: 3] (through reference chain: de.gematik.refv.commons.configuration.ValidationModuleConfiguration["fhirPackages"]->java.util.LinkedHashMap["kbv.ita.erp"]->de.gematik.refv.commons.configuration.PackageDefinitionByVersion["packageName"])
    at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
    at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:1132)
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:2202)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1705)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperties(BeanDeserializerBase.java:1655)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:540)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1405)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:352)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
    at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:623)
    at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:449)
    at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:32)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
    at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4722)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3714)
    at de.gematik.refv.commons.configuration.FhirPackageConfigurationLoader.getConfiguration(FhirPackageConfigurationLoader.java:47)
    at de.gematik.refv.valmodule.erp.ErpValidationModule.initialize(ErpValidationModule.java:67)
    ... 80 more
alexey-tschudnowsky commented 2 years ago

Thanks for the bug report!

It would be really helpful, if you describe the context where the exception occured:

  1. Are you using the validator as maven dependency, as CLI or are you trying to compile the source code? Which release of the validator? Please post your call to the validator (source code or CLI command)
  2. Which Java SDK and operating system are you using?
  3. What FHIR profile / version is used in the resource you are trying to validate?
joergreichert commented 2 years ago

Sure, here is the requested information

the Maven dependency:

        <dependency>
            <groupId>de.gematik.refv</groupId>
            <artifactId>referencevalidator-lib</artifactId>
            <version>0.1.3</version>
        </dependency>

and com.fasterxml.jackson.core:jackson-databind:jar:2.14.0-rc3:compile (as there the exception occurs).

The call in Kotlin JUnit5 test factory:

    @org.junit.jupiter.api.TestFactory
    fun eEPrescriptionExampleTests(): Collection<DynamicTest?> {
        return testCases.mapIndexed { index, testCase ->
            DynamicTest.dynamicTest("Testfall ${index + 1}") {
                val content = "..."
        val gematikReferenceValidator = ValidationModuleFactory().createValidationModule(SupportedValidationModule.ERP)
        val result: ValidationResult = gematikReferenceValidator.validateString(content)
        assertTrue(result.isValid, "result should be valid")
            }
        }.flatten().flatten()
    }

Java: OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-122.04, mixed mode, sharing

FHIR-Profile within the validated resource: https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle|1.0.2

joergreichert commented 2 years ago

Loading the packages.yaml file directly works through. Just checked my test set up again and remove the loading of the Abda reference validator and the customly configured ca.uhn.fhir.validation.FhirValidator (just wanted to compare the validation results of the different approaches / validators) resolved the problem. Still wouldn't expected that the validators interfere with each other.

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import de.gematik.refv.commons.configuration.ValidationModuleConfiguration
import org.junit.jupiter.api.Test

class YamlTest {

    @Test
    fun testYaml() {
        val mapper = ObjectMapper(YAMLFactory())
        val validationModuleConfiguration = mapper.readValue<ValidationModuleConfiguration>(javaClass.getResourceAsStream("/packages.yaml"), ValidationModuleConfiguration::class.java) as ValidationModuleConfiguration
    }
}
alexey-tschudnowsky commented 2 years ago

Indeed, the two two validators interfere. Unfortunately, they cannot be used simulatenously in one process, because they both come with resources named "packages.yaml" and the resource loading algorithm can't distinguish between the two (https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ClassLoader.html#getResource(java.lang.String)).

You might consider calling both or only the second validator in a new process (either via CLI or using a custom wrapper) and compare results.

alexey-tschudnowsky commented 2 years ago

The parallel operation with ABDA validator in one process is not a supported use case at the moment, so the issue will be closed.