diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/kotlin/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandler.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive/kotlin/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandler.kt index b68f2dde588c6..4cf40d8098dae 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/kotlin/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandler.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/kotlin/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandler.kt @@ -4,7 +4,6 @@ import io.vertx.core.Vertx import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import org.eclipse.microprofile.context.ManagedExecutor import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext import org.jboss.resteasy.reactive.server.spi.EndpointInvoker import org.jboss.resteasy.reactive.server.spi.ServerRestHandler @@ -15,6 +14,9 @@ private val logger = LoggerFactory.getLogger(CoroutineInvocationHandler::class.j class CoroutineInvocationHandler(private val invoker: EndpointInvoker, private val coroutineScope: CoroutineScope) : ServerRestHandler { + private val originalTCCL: ClassLoader = Thread.currentThread().contextClassLoader + + override fun handle(requestContext: ResteasyReactiveRequestContext) { if (requestContext.result != null) { return @@ -32,6 +34,8 @@ class CoroutineInvocationHandler(private val invoker: EndpointInvoker, requestContext.suspend() coroutineScope.launch(context = dispatcher) { + // ensure the proper CL is not lost in dev-mode + Thread.currentThread().contextClassLoader = originalTCCL try { requestContext.result = invoker.invokeCoroutine(requestContext.endpointInstance, requestContext.parameters) } catch (t: Throwable) {