FHIR Chat · Java cast error in JAR validator · implementers

Stream: implementers

Topic: Java cast error in JAR validator


view this post on Zulip Morten Ernebjerg (Oct 15 2018 at 12:41):

End of last week, I started seeing the following Java error being thrown by the latest version of the standard JAR validator (https://build.fhir.org/validator.zip) when validating STU3 resources:

Error java.lang.ClassCastException: org.hl7.fhir.r4.model.Parameters cannot be cast to org.hl7.fhir.r4.model.TerminologyCapabilities validating Coding`

For instance, here is the output when running against one of the standard STU3 examples (https://www.hl7.org/fhir/observation-example.xml):

java -jar org.hl7.fhir.validator.jar -version 3.0.1 observation-example.xml
FHIR Validator Build ??
Arguments: -version 3.0.1 observation-example.xml
  .. connect to tx server @ http://tx.fhir.org
  .. definitions from hl7.fhir.core#3.0.1
    (v3.0.1-null)
  .. validate [observation-example.xml]
Terminology server: Check for supported code systems for http://loinc.org
Terminology server: Check for supported code systems for http://loinc.org
Terminology server: Check for supported code systems for http://acme.org/devices/clinical-codes
*FAILURE* validating observation-example.xml:  error:4 warn:0 info:0
  Error @ Observation.code.coding[1] (line 21, col11) : Error java.lang.ClassCastException: org.hl7.fhir.r4.model.Parameters cannot be cast to org.hl7.fhir.r4.model.TerminologyCapabilities validating Coding
  Error @ Observation.code.coding[2] (line 26, col11) : Error java.lang.ClassCastException: org.hl7.fhir.r4.model.Parameters cannot be cast to org.hl7.fhir.r4.model.TerminologyCapabilities validating Coding
  Error @ Observation.code.coding[3] (line 32, col11) : Code system validation not supported in R2
  Error @ Observation.code.coding[4] (line 38, col11) : Error java.lang.ClassCastException: org.hl7.fhir.r4.model.Parameters cannot be cast to org.hl7.fhir.r4.model.TerminologyCapabilities validating Coding

Has anyone seen this or, even better, know a way around it?

Running without a terminology server (-tx n/a) does not lead to the above error. However, I see that using this option now itself causes the validation to fail (Error validating code: running without terminology services), which I do not quite understand. After all, I explicitly switched it off and the validator outputs a large warning about this at the top, so why is this also a validation error for the resource? Is there now some other way to switch of terminology checks without causing an error (e.g. to avoid a CI pipeline with automatic validation breaking if no terminology server is available)?

view this post on Zulip Grahame Grieve (Oct 15 2018 at 13:01):

do you get a stack dump?

view this post on Zulip Morten Ernebjerg (Oct 15 2018 at 14:04):

I only get the output I pasted in above (not sure how I can convince the JVM to say more...)

view this post on Zulip Michael Riley (Oct 15 2018 at 14:52):

Without knowing how you ran the validator, this looks like a FHIR version issue. That's an R4 (release candidate 4/STU4) class, so it shouldn't be used to validate STU3 resources. The right class would be org.hl7.fhir.dstu3.model.Parameters.

Unless I'm misunderstanding and you intended to validate R4 resources?

view this post on Zulip Grahame Grieve (Oct 15 2018 at 17:54):

this is a bug in the validator. I'm mystified how this passes the JUnit tests that are part of the build that run exactly this test. because due to a bug in my code this will fail.

view this post on Zulip Grahame Grieve (Oct 15 2018 at 18:42):

found and fixed the problems, and added a few more tests. Will let you know when it is released

view this post on Zulip Grahame Grieve (Oct 15 2018 at 20:15):

released

view this post on Zulip Morten Ernebjerg (Oct 16 2018 at 06:53):

Awesome, thank you @Grahame Grieve!


Last updated: Apr 12 2022 at 19:14 UTC