Stream: hapi
Topic: Java Core dependency issue
Grahame Grieve (Dec 11 2019 at 09:16):
@James Agnew I just added a JUnit test case that has a dependency on the NarrativeGenerator, which executes the following line of code:
Set<Extension> extensions = Collections.singleton(TablesExtension.create());
TablesExtension is org.commonmark.ext.gfm.tables.TablesExtension which would appear to be covered by this import in the POM:
<dependency> <groupId>com.atlassian.commonmark</groupId> <artifactId>commonmark</artifactId> <version>0.12.1</version> </dependency> <dependency> <groupId>com.atlassian.commonmark</groupId> <artifactId>commonmark-ext-gfm-tables</artifactId> <version>0.12.1</version> </dependency>
Grahame Grieve (Dec 11 2019 at 09:16):
but... when I run it, I get:
Grahame Grieve (Dec 11 2019 at 09:17):
java.lang.NoClassDefFoundError: org/commonmark/ext/gfm/tables/TablesExtension at org.hl7.fhir.utilities.MarkDownProcessor.processCommonMark(MarkDownProcessor.java:57)
Grahame Grieve (Dec 11 2019 at 09:17):
I don't understand this?
Grahame Grieve (Dec 11 2019 at 09:20):
no:
java.lang.NoClassDefFoundError: org/commonmark/parser/Parser
at org.hl7.fhir.utilities.MarkDownProcessor.processCommonMark(MarkDownProcessor.java:58)
Grahame Grieve (Dec 11 2019 at 09:25):
none of the commonmark code is available, but I don't know why
James Agnew (Dec 12 2019 at 14:21):
Are you getting this in Maven build or Eclipse?
Patrick Werner (Dec 12 2019 at 14:48):
i got the same error yesterday, but its gone in the current ci version (which has other problems)
Patrick Werner (Dec 12 2019 at 14:58):
I just checked the pom, the dependencies are entered with the optional flag set to true. So (if i remember correctly) if the utilities module is used in the R5 module the dependency to commonmark has to be stated explicitly again.
Or remove the optional in the utilities pom
James Agnew (Dec 12 2019 at 15:19):
I don't think this should be made a non-optional dependency though. That would mean that anyone using hapi for any purpose will get commonmark imported into their project (specifically I know this will break android)
It'd be better for it to be added as a dependency with <scope>test</scope>
on the project that has the tests
Patrick Werner (Dec 12 2019 at 15:21):
yes sounds great.
Grahame Grieve (Dec 12 2019 at 19:01):
umm how is it optional?
James Agnew (Dec 12 2019 at 19:04):
that's this line (which should be there): https://github.com/hapifhir/org.hl7.fhir.core/blob/master/org.hl7.fhir.utilities/pom.xml#L33
James Agnew (Dec 12 2019 at 19:04):
solution is to copy these two new dependencies to the pom for the project where the tests are, but replace <optional>true</optional>
with <scope>test</scope>
Patrick Werner (Dec 12 2019 at 19:05):
which test is causing the NoClassDefError?
Grahame Grieve (Dec 12 2019 at 19:17):
the NarrativeGenerationTests clas ins R5, if you add a description to one of the classes in test-cases/R5/narrative
Grahame Grieve (Dec 12 2019 at 19:18):
.. but... Android doesn't support commonmark? wtf?
Patrick Werner (Dec 12 2019 at 19:38):
the NarrativeGenerationTests clas ins R5, if you add a description to one of the classes in test-cases/R5/narrative
i added the dependencies test-scoped to the module:
https://github.com/hapifhir/org.hl7.fhir.core/tree/commonmark_dependency
Is it working now?
Grahame Grieve (Dec 12 2019 at 19:41):
yes thanks
Patrick Werner (Dec 12 2019 at 19:45):
.. but... Android doesn't support commonmark? wtf?
according to this: https://github.com/atlassian/commonmark-java it should work. Since Api Level 24 the Java8 support is quite good
Patrick Werner (Dec 12 2019 at 19:56):
and glad that it works now, added a PR. I am now wondering if this really should be an optional dependency. As i understand the cause of the Exception, this would happen to any implementer using the parser from fhir.core on a R5 resource with a description element, right?
Patrick Werner (Dec 12 2019 at 20:00):
also the validator would fail on any r5 resources with a description. Could have different build profiles: one for r5, one for r4 and below.
Grahame Grieve (Dec 12 2019 at 20:02):
no it's only when you try to process the markdown for display. We don't do that at parse time. The NarrativeGenerator does
Patrick Werner (Dec 12 2019 at 20:05):
ahh.
Patrick Werner (Dec 12 2019 at 20:05):
ok, forget everything i said then :dizzy:
Patrick Werner (Dec 12 2019 at 20:12):
Thought commonmark was used to check if description contains valid markdown
Grahame Grieve (Dec 12 2019 at 20:36):
there's no such thing as invalid markdown
Grahame Grieve (Dec 12 2019 at 22:33):
so I went to do the release, and:
[ERROR] [ERROR] Some problems were encountered while processing the POMs: [ERROR] 'dependencies.dependency.optional' for com.atlassian.commonmark:commonmark:jar must be 'true' or 'false' but is 'test'. @ ca.uhn.hapi.fhir:org.hl7.fhir.r5:[unknown-version], C:\work\org.hl7.fhir\org.hl7.fhir.core\org.hl7.fhir.r5\pom.xml, line 114, column 19 [ERROR] 'dependencies.dependency.optional' for com.atlassian.commonmark:commonmark-ext-gfm-tables:jar must be 'true' or 'false' but is 'test'. @ ca.uhn.hapi.fhir:org.hl7.fhir.r5:[unknown-version], C:\work\org.hl7.fhir\org.hl7.fhir.core\org.hl7.fhir.r5\pom.xml, line 119, column 19 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project ca.uhn.hapi.fhir:org.hl7.fhir.r5:4.1.23-SNAPSHOT (C:\work\org.hl7.fhir\org.hl7.fhir.core\org.hl7.fhir.r5\pom.xml) has 2 errors [ERROR] 'dependencies.dependency.optional' for com.atlassian.commonmark:commonmark:jar must be 'true' or 'false' but is 'test'. @ ca.uhn.hapi.fhir:org.hl7.fhir.r5:[unknown-version], C:\work\org.hl7.fhir\org.hl7.fhir.core\org.hl7.fhir.r5\pom.xml, line 114, column 19 [ERROR] 'dependencies.dependency.optional' for com.atlassian.commonmark:commonmark-ext-gfm-tables:jar must be 'true' or 'false' but is 'test'. @ ca.uhn.hapi.fhir:org.hl7.fhir.r5:[unknown-version], C:\work\org.hl7.fhir\org.hl7.fhir.core\org.hl7.fhir.r5\pom.xml, line 119, column 19
Patrick Werner (Dec 12 2019 at 22:49):
sorry, messed up the copy & pasting. Just pushed a fix in the branch
Patrick Werner (Dec 12 2019 at 22:56):
ah you didn't merge my PR, sec.
Grahame Grieve (Dec 12 2019 at 22:59):
I can merge your PR. But I had actually copied what you did before you did the PR
Patrick Werner (Dec 12 2019 at 23:01):
i merged a fix in the master, the mistake was that it has to be <scope>test
and it was <optional>test
Grahame Grieve (Dec 12 2019 at 23:04):
thanks
Last updated: Apr 12 2022 at 19:14 UTC