-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the bug
Hello,
I'm using quarkus-spring-di, quarkus-spring-data-jpa,quarkus-spring-web
in my project. but i've a problem...
I'm trying to create a Global Exception Handler, i read the docs but i can't to create it with Spring annotation.
This is my configuration:
Handler Class:
@Slf4j
@RestControllerAdvice
class ExceptionMappersSpring {
@ExceptionHandler({JpaQueryException.class})
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public RestResponse<BaseCustomExceptionDto> internalServerError(RuntimeException exception) {
log.error("Internal server error occurred ", exception);
return RestResponse.status(Response.Status.INTERNAL_SERVER_ERROR,
BaseCustomExceptionDto.builder()
.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
.message(exception.getMessage())
.timestamp(System.currentTimeMillis())
.build()
);
}
@ExceptionHandler({BadRequestException.class})
@ResponseStatus(HttpStatus.BAD_REQUEST)
public RestResponse<BaseCustomExceptionDto> badRequest(RuntimeException exception) {
log.error("Bad Request exception occurred ", exception);
return RestResponse.status(Response.Status.BAD_REQUEST,
BaseCustomExceptionDto.builder()
.status(Response.Status.BAD_REQUEST.getStatusCode())
.message(exception.getMessage())
.timestamp(System.currentTimeMillis())
.build()
);
}
}
Controller:
@RestController
@RequestMapping("/test")
public class TestController {
@GetMapping(value = "/exception", produces = MediaType.APPLICATION_JSON_VALUE)
public Factsheet customException(@RestQuery(value = "firstException") boolean firstException) {
if (firstException) {
throw new JpaQueryException("This is an illegal argument exception");
} else {
throw new BadRequestException("Custom bad request exception");
}
}
}
Expected behavior
What I expect is that every time my endpoint /exception
is invoked, the exception is intercepted by my ExceptionMappersSpring class, the response is constructed as indicated, and then returned.
In short, what is normally done in the exception handler—nothing unusual.
Actual behavior
What happens when the exception is triggered is that the project crashes with the following message:
2025-09-23 12:33:05,834 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /test/exception?firstException=true failed, error id: 8acdd505-df9f-4d0b-842d-303ed0eb29e2-1: java.lang.IllegalAccessError: failed to access class it.exante.handler.ExceptionMappersSpring from class io.quarkus.spring.web.mappers.JpaQueryException_Mapper_ef08d5d281100ccf9ae0a56472a4fb5e5389736f (it.exante.handler.ExceptionMappersSpring and io.quarkus.spring.web.mappers.JpaQueryException_Mapper_ef08d5d281100ccf9ae0a56472a4fb5e5389736f are in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @f25f48a)
at io.quarkus.spring.web.mappers.JpaQueryException_Mapper_ef08d5d281100ccf9ae0a56472a4fb5e5389736f.toResponse(Unknown Source)
at io.quarkus.spring.web.mappers.JpaQueryException_Mapper_ef08d5d281100ccf9ae0a56472a4fb5e5389736f.toResponse(Unknown Source)
at org.jboss.resteasy.reactive.server.core.RuntimeExceptionMapper.mapException(RuntimeExceptionMapper.java:96)
at org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext.mapExceptionIfPresent(ResteasyReactiveRequestContext.java:408)
at org.jboss.resteasy.reactive.server.handlers.ExceptionHandler.handle(ExceptionHandler.java:15)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:192)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:645)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:1583)
How to Reproduce?
Download the zip, run the application.
try to interrogate the endpoint localhost:8080/test/exception?firstException=true
the exception will be raise
quarkus-exception-handler-test.zip
Output of uname -a
or ver
No response
Output of java -version
21
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version
or gradlew --version
)
mvn 3.9.9
Additional information
No response