Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] java.lang.LinkageError loading javax.xml.namespace.QName #6204

Closed
phommata opened this issue May 21, 2024 · 1 comment
Closed

[BUG] java.lang.LinkageError loading javax.xml.namespace.QName #6204

phommata opened this issue May 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@phommata
Copy link

Describe the bug

Error parsing the JSON appointment resource using Hapi FHIR 7.2.0, I get Mirth java.lang.LinkageError loading javax.xml.namespace.QName since a different class with same name QName in module java.xml was loaded by 'bootstrap'.

To Reproduce
Setup steps

  1. Run JDK 17
  2. Run Mirth Connect 4.5.0
  3. Download Hapi FHIR 7.2.0 to custom-libs from GitHub releases

Steps to reproduce the behavior:

  1. Run code below in a JavaScript destination connector
  2. See error

`
// Create a HAPI FHIR context for FHIR
var context = new Packages.ca.uhn.fhir.context.FhirContext.forR4();

// Instantiate a new parser
var parser = ctx.newJsonParser();

var input = {
{
"resourceType" : "Appointment",
"status" : "booked"
};

// Parse it
var appointment = parser.parseResource(Packages.org.hl7.fhir.r4.model.Appointment, JSON.stringify(input));

ERROR (com.mirth.connect.connectors.js.JavaScriptDispatcher:305): Error evaluating JavaScript Writer (JavaScript Writer "Parsing Appointment" on channel 580496cb-4e73-4584-b43b-2d157216edf7).
java.lang.LinkageError: loader constraint violation: loader com.mirth.connect.server.util.ChildFirstURLClassLoader @28d3c841 wants to load class javax.xml.namespace.QName. A different class with the same name was previously loaded by 'bootstrap'. (javax.xml.namespace.QName is in module java.xml of loader 'bootstrap')
at com.ctc.wstx.compat.QNameCreator.create(QNameCreator.java:52)
at com.ctc.wstx.sr.InputElementStack.getCurrentElementName(InputElementStack.java:832)
at com.ctc.wstx.sr.BasicStreamReader.getName(BasicStreamReader.java:786)
at com.ctc.wstx.sr.BasicStreamReader.withStartElement(BasicStreamReader.java:1735)
at com.ctc.wstx.evt.DefaultEventAllocator.allocate(DefaultEventAllocator.java:185)
at com.ctc.wstx.evt.WstxEventReader.createNextEvent(WstxEventReader.java:463)
at com.ctc.wstx.evt.WstxEventReader.nextEvent(WstxEventReader.java:283)
at ca.uhn.fhir.util.XmlUtil.parse(XmlUtil.java:1839)
at ca.uhn.fhir.model.primitive.XhtmlDt.parse(XhtmlDt.java:82)
at ca.uhn.fhir.model.primitive.XhtmlDt.parse(XhtmlDt.java:40)
at ca.uhn.fhir.model.api.BasePrimitive.setValueAsString(BasePrimitive.java:111)
at ca.uhn.fhir.model.primitive.XhtmlDt.setValueAsString(XhtmlDt.java:130)
at ca.uhn.fhir.parser.ParserState$XhtmlState.attributeValue(ParserState.java:1693)
at ca.uhn.fhir.parser.ParserState.attributeValue(ParserState.java:112)
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1452)
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1339)
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1439)
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1339)
at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:262)
at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:242)
at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:683)
at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:738)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:226)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1692)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1013)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:412)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3578)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:121)
at com.mirth.connect.server.util.javascript.JavaScriptTask.executeScript(JavaScriptTask.java:151)
at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:261)
at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:221)
at com.mirth.connect.server.util.javascript.JavaScriptTask.call(JavaScriptTask.java:114)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:842)
`

Expected behavior
I expect the JSON parser to successfully load and parse the JSON string.

Actual behavior
Mirth java.lang.LinkageError loading javax.xml.namespace.QName since a different class with same name QName in module java.xml was loaded by 'bootstrap'.

Screenshots
None

Environment (please complete the following information):

  • OS: MacOS
  • Java Distribution/Version Java 17
  • Connect Version 4.5.0

Workaround(s)
I can use vanilla JavaScript.

Additional context
I am able to successfully run the Hapi HL7 examples.

@phommata phommata added the bug Something isn't working label May 21, 2024
@phommata
Copy link
Author

Try this:
Create a completely new folder somewhere, for example "custom-oracle-driver".
On the Settings -> Resources tab, create a new Directory resource pointing to that folder. After saving and refreshing, you should see your JAR appear in the table below.
Edit your channel and go into Summary -> Set Dependencies -> Library Resources. Select the connector you want, and make sure only your new resource is checked.

Now, your connector or JavaScript should be able to create database connections using the specific version of the JAR you included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant