Repository navigation
Fix Web Service Listener SOAP requests failing on JDK 19+ #508
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
Merged
tonygermano
merged 3 commits into
OpenIntegrationEngine:main
from
jonbartels:fix/ws-listener-jdk19-classloader
Nov 1, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
server/src/test/java/com/mirth/connect/connectors/ws/WebServiceReceiverTest.java
|
jonbartels marked this conversation as resolved.
Resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
| // SPDX-FileCopyrightText: Open Integration Engine Contributors | ||
|
|
||
| package com.mirth.connect.connectors.ws; | ||
|
|
||
| import static org.junit.Assert.assertSame; | ||
|
|
||
| import java.net.HttpURLConnection; | ||
| import java.net.InetSocketAddress; | ||
| import java.net.URI; | ||
| import java.net.URL; | ||
| import java.net.URLClassLoader; | ||
| import java.util.concurrent.CompletableFuture; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| import com.sun.net.httpserver.HttpServer; | ||
|
|
||
| public class WebServiceReceiverTest { | ||
|
|
||
| @Test | ||
| public void testWorkerThreadsUseGivenContextClassLoader() throws Exception { | ||
| try (URLClassLoader expected = new URLClassLoader(new URL[0], getClass().getClassLoader())) { | ||
| CompletableFuture<ClassLoader> actual = new CompletableFuture<>(); | ||
|
|
||
| HttpServer server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0); | ||
| ExecutorService executor = WebServiceReceiver.createExecutor(1, expected); | ||
| server.setExecutor(executor); | ||
| server.createContext("/", exchange -> { | ||
| actual.complete(Thread.currentThread().getContextClassLoader()); | ||
| exchange.sendResponseHeaders(204, -1); | ||
| exchange.close(); | ||
| }); | ||
| server.start(); | ||
|
|
||
| try { | ||
| HttpURLConnection connection = (HttpURLConnection) URI.create("http://127.0.0.1:" + server.getAddress().getPort() + "/").toURL().openConnection(); | ||
| connection.getResponseCode(); | ||
| connection.disconnect(); | ||
|
|
||
| assertSame(expected, actual.get(10, TimeUnit.SECONDS)); | ||
| } finally { | ||
| server.stop(0); | ||
| executor.shutdown(); | ||
| } | ||
| } | ||
| } | ||
| } |
76 changes: 76 additions & 0 deletions
76
smoketest/src/test/java/org/openintegrationengine/smoketest/WebServiceListenerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
| // SPDX-FileCopyrightText: Open Integration Engine Contributors | ||
|
|
||
| package org.openintegrationengine.smoketest; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import java.net.URI; | ||
| import java.net.http.HttpClient; | ||
| import java.net.http.HttpRequest; | ||
| import java.net.http.HttpResponse; | ||
| import java.time.Duration; | ||
|
|
||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Sends a SOAP request to a deployed Web Service Listener. Messages submitted through the client | ||
| * API never reach the listener's HTTP worker threads, which is where SAAJ is resolved, so the | ||
| * fixture tests cannot cover this. | ||
| */ | ||
| @DisplayName("Web Service Listener") | ||
| class WebServiceListenerTest { | ||
|
|
||
| /** The listener port and service name in web-service-listener/channel.xml. */ | ||
| private static final int PORT = 8081; | ||
| private static final String SERVICE = "Mirth"; | ||
|
|
||
| private static final String ENVELOPE = """ | ||
| <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.connectors.connect.mirth.com/"> | ||
| <soapenv:Body> | ||
| <ws:acceptMessage> | ||
| <arg0>smoke test</arg0> | ||
| </ws:acceptMessage> | ||
| </soapenv:Body> | ||
| </soapenv:Envelope> | ||
| """; | ||
|
|
||
| private static String channelId; | ||
|
|
||
| @BeforeAll | ||
| static void deploy() throws Exception { | ||
| channelId = Harness.deploy("web-service-listener/channel.xml"); | ||
| } | ||
|
|
||
| @AfterAll | ||
| static void undeploy() { | ||
| Harness.undeploy(channelId); | ||
| } | ||
|
|
||
| /** | ||
| * On JDK 19 and later the listener's worker threads lost the server classloader, so every | ||
| * request failed with "Unable to create SAAJ meta-factory" while the WSDL still served fine. | ||
| */ | ||
| @Test | ||
| @DisplayName("accepts a SOAP request") | ||
| void acceptsSoapRequest() throws Exception { | ||
| URI endpoint = new URI("http", null, URI.create(HarnessConfig.BASE_URL).getHost(), PORT, | ||
| "/services/" + SERVICE, null, null); | ||
|
|
||
| HttpRequest request = HttpRequest.newBuilder(endpoint) | ||
| .timeout(Duration.ofMillis(HarnessConfig.REQUEST_TIMEOUT_MILLIS)) | ||
| .header("Content-Type", "text/xml; charset=utf-8") | ||
| .header("SOAPAction", "\"\"") | ||
| .POST(HttpRequest.BodyPublishers.ofString(ENVELOPE)) | ||
| .build(); | ||
|
|
||
| HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); | ||
|
|
||
| assertEquals(200, response.statusCode(), () -> "status of POST " + endpoint + ": " + response.body()); | ||
| assertTrue(response.body().contains("acceptMessageResponse"), () -> "response body: " + response.body()); | ||
| } | ||
| } |
191 changes: 191 additions & 0 deletions
191
smoketest/src/test/resources/web-service-listener/channel.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| <channel version="4.5.2"> | ||
| <id>f7ed972e-6845-45bf-92bc-0302d6b05204</id> | ||
| <nextMetaDataId>2</nextMetaDataId> | ||
| <name>Web Service Listener</name> | ||
| <description></description> | ||
| <revision>1</revision> | ||
| <sourceConnector version="4.5.2"> | ||
| <metaDataId>0</metaDataId> | ||
| <name>sourceConnector</name> | ||
| <properties class="com.mirth.connect.connectors.ws.WebServiceReceiverProperties" version="4.5.2"> | ||
| <pluginProperties/> | ||
| <listenerConnectorProperties version="4.5.2"> | ||
| <host>0.0.0.0</host> | ||
| <port>8081</port> | ||
| </listenerConnectorProperties> | ||
| <sourceConnectorProperties version="4.5.2"> | ||
| <responseVariable>None</responseVariable> | ||
| <respondAfterProcessing>true</respondAfterProcessing> | ||
| <processBatch>false</processBatch> | ||
| <firstResponse>false</firstResponse> | ||
| <processingThreads>1</processingThreads> | ||
| <resourceIds class="linked-hash-map"> | ||
| <entry> | ||
| <string>Default Resource</string> | ||
| <string>[Default Resource]</string> | ||
| </entry> | ||
| </resourceIds> | ||
| <queueBufferSize>1000</queueBufferSize> | ||
| </sourceConnectorProperties> | ||
| <className>com.mirth.connect.connectors.ws.DefaultAcceptMessage</className> | ||
| <serviceName>Mirth</serviceName> | ||
| <soapBinding>DEFAULT</soapBinding> | ||
| </properties> | ||
| <transformer version="4.5.2"> | ||
| <elements/> | ||
| <inboundDataType>RAW</inboundDataType> | ||
| <outboundDataType>RAW</outboundDataType> | ||
| <inboundProperties class="com.mirth.connect.plugins.datatypes.raw.RawDataTypeProperties" version="4.5.2"> | ||
| <batchProperties class="com.mirth.connect.plugins.datatypes.raw.RawBatchProperties" version="4.5.2"> | ||
| <splitType>JavaScript</splitType> | ||
| <batchScript></batchScript> | ||
| </batchProperties> | ||
| </inboundProperties> | ||
| <outboundProperties class="com.mirth.connect.plugins.datatypes.raw.RawDataTypeProperties" version="4.5.2"> | ||
| <batchProperties class="com.mirth.connect.plugins.datatypes.raw.RawBatchProperties" version="4.5.2"> | ||
| <splitType>JavaScript</splitType> | ||
| <batchScript></batchScript> | ||
| </batchProperties> | ||
| </outboundProperties> | ||
| </transformer> | ||
| <filter version="4.5.2"> | ||
| <elements/> | ||
| </filter> | ||
| <transportName>Web Service Listener</transportName> | ||
| <mode>SOURCE</mode> | ||
| <enabled>true</enabled> | ||
| <waitForPrevious>true</waitForPrevious> | ||
| </sourceConnector> | ||
| <destinationConnectors> | ||
| <connector version="4.5.2"> | ||
| <metaDataId>1</metaDataId> | ||
| <name>Destination 1</name> | ||
| <properties class="com.mirth.connect.connectors.vm.VmDispatcherProperties" version="4.5.2"> | ||
| <pluginProperties/> | ||
| <destinationConnectorProperties version="4.5.2"> | ||
| <queueEnabled>false</queueEnabled> | ||
| <sendFirst>false</sendFirst> | ||
| <retryIntervalMillis>10000</retryIntervalMillis> | ||
| <regenerateTemplate>false</regenerateTemplate> | ||
| <retryCount>0</retryCount> | ||
| <rotate>false</rotate> | ||
| <includeFilterTransformer>false</includeFilterTransformer> | ||
| <threadCount>1</threadCount> | ||
| <threadAssignmentVariable></threadAssignmentVariable> | ||
| <validateResponse>false</validateResponse> | ||
| <resourceIds class="linked-hash-map"> | ||
| <entry> | ||
| <string>Default Resource</string> | ||
| <string>[Default Resource]</string> | ||
| </entry> | ||
| </resourceIds> | ||
| <queueBufferSize>1000</queueBufferSize> | ||
| <reattachAttachments>true</reattachAttachments> | ||
| </destinationConnectorProperties> | ||
| <channelId>none</channelId> | ||
| <channelTemplate>${message.encodedData}</channelTemplate> | ||
| <mapVariables/> | ||
| </properties> | ||
| <transformer version="4.5.2"> | ||
| <elements/> | ||
| <inboundDataType>RAW</inboundDataType> | ||
| <outboundDataType>RAW</outboundDataType> | ||
| <inboundProperties class="com.mirth.connect.plugins.datatypes.raw.RawDataTypeProperties" version="4.5.2"> | ||
| <batchProperties class="com.mirth.connect.plugins.datatypes.raw.RawBatchProperties" version="4.5.2"> | ||
| <splitType>JavaScript</splitType> | ||
| <batchScript></batchScript> | ||
| </batchProperties> | ||
| </inboundProperties> | ||
| <outboundProperties class="com.mirth.connect.plugins.datatypes.raw.RawDataTypeProperties" version="4.5.2"> | ||
| <batchProperties class="com.mirth.connect.plugins.datatypes.raw.RawBatchProperties" version="4.5.2"> | ||
| <splitType>JavaScript</splitType> | ||
| <batchScript></batchScript> | ||
| </batchProperties> | ||
| </outboundProperties> | ||
| </transformer> | ||
| <responseTransformer version="4.5.2"> | ||
| <elements/> | ||
| <inboundDataType>RAW</inboundDataType> | ||
| <outboundDataType>RAW</outboundDataType> | ||
| <inboundProperties class="com.mirth.connect.plugins.datatypes.raw.RawDataTypeProperties" version="4.5.2"> | ||
| <batchProperties class="com.mirth.connect.plugins.datatypes.raw.RawBatchProperties" version="4.5.2"> | ||
| <splitType>JavaScript</splitType> | ||
| <batchScript></batchScript> | ||
| </batchProperties> | ||
| </inboundProperties> | ||
| <outboundProperties class="com.mirth.connect.plugins.datatypes.raw.RawDataTypeProperties" version="4.5.2"> | ||
| <batchProperties class="com.mirth.connect.plugins.datatypes.raw.RawBatchProperties" version="4.5.2"> | ||
| <splitType>JavaScript</splitType> | ||
| <batchScript></batchScript> | ||
| </batchProperties> | ||
| </outboundProperties> | ||
| </responseTransformer> | ||
| <filter version="4.5.2"> | ||
| <elements/> | ||
| </filter> | ||
| <transportName>Channel Writer</transportName> | ||
| <mode>DESTINATION</mode> | ||
| <enabled>true</enabled> | ||
| <waitForPrevious>true</waitForPrevious> | ||
| </connector> | ||
| </destinationConnectors> | ||
| <preprocessingScript>// Modify the message variable below to pre process data | ||
| return message;</preprocessingScript> | ||
| <postprocessingScript>// This script executes once after a message has been processed | ||
| // Responses returned from here will be stored as "Postprocessor" in the response map | ||
| return;</postprocessingScript> | ||
| <deployScript>// This script executes once when the channel is deployed | ||
| // You only have access to the globalMap and globalChannelMap here to persist data | ||
| return;</deployScript> | ||
| <undeployScript>// This script executes once when the channel is undeployed | ||
| // You only have access to the globalMap and globalChannelMap here to persist data | ||
| return;</undeployScript> | ||
| <properties version="4.5.2"> | ||
| <clearGlobalChannelMap>true</clearGlobalChannelMap> | ||
| <messageStorageMode>DEVELOPMENT</messageStorageMode> | ||
| <encryptData>false</encryptData> | ||
| <encryptAttachments>false</encryptAttachments> | ||
| <encryptCustomMetaData>false</encryptCustomMetaData> | ||
| <removeContentOnCompletion>false</removeContentOnCompletion> | ||
| <removeOnlyFilteredOnCompletion>false</removeOnlyFilteredOnCompletion> | ||
| <removeAttachmentsOnCompletion>false</removeAttachmentsOnCompletion> | ||
| <initialState>STARTED</initialState> | ||
| <storeAttachments>true</storeAttachments> | ||
| <metaDataColumns> | ||
| <metaDataColumn> | ||
| <name>SOURCE</name> | ||
| <type>STRING</type> | ||
| <mappingName>mirth_source</mappingName> | ||
| </metaDataColumn> | ||
| <metaDataColumn> | ||
| <name>TYPE</name> | ||
| <type>STRING</type> | ||
| <mappingName>mirth_type</mappingName> | ||
| </metaDataColumn> | ||
| </metaDataColumns> | ||
| <attachmentProperties version="4.5.2"> | ||
| <type>None</type> | ||
| <properties/> | ||
| </attachmentProperties> | ||
| <resourceIds class="linked-hash-map"> | ||
| <entry> | ||
| <string>Default Resource</string> | ||
| <string>[Default Resource]</string> | ||
| </entry> | ||
| </resourceIds> | ||
| </properties> | ||
| <exportData> | ||
| <metadata> | ||
| <enabled>true</enabled> | ||
| <lastModified> | ||
| <time>1775955953073</time> | ||
| <timezone>America/Chicago</timezone> | ||
| </lastModified> | ||
| <pruningSettings> | ||
| <archiveEnabled>true</archiveEnabled> | ||
| <pruneErroredMessages>false</pruneErroredMessages> | ||
| </pruningSettings> | ||
| <userId>1</userId> | ||
| </metadata> | ||
| </exportData> | ||
| </channel> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.