javarestexceptionquarkusquarkus-extension

Issue with Quarkus exception handling extension not capturing exceptions


I’m working on several Quarkus APIs that communicate via REST within a Kubernetes cluster. I’ve implemented an exception handling mechanism that captures exceptions, formats them to match a standard, and returns them. The solution is based on the implementation of the ResponseExceptionMapper and ExceptionMapper interfaces from JAX-RS. As shared code between the APIs, it works perfectly fine.

Recently, with the increasing number of APIs, I decided to refactor the exception handling into a Quarkus extension that can be deployed alongside all my APIs. The extension seems to load correctly in our Quarkus APIs, but exceptions are not being captured. When an exception is thrown, the code in the extension is not executed. As a result, a 500 error occurs.

I’ve tried implementing a Recorder, but it hasn’t worked. I’m still relatively new to Quarkus, and AI tools haven’t been very helpful. I’m sure the issue is simple, but I can’t seem to figure it out. I’d really appreciate any help you can offer!

Here’s a link to a quickly created GitHub project that contains the code for the extension: GitHub - Quarkus Exception Handler

Thanks in advance for your kind assistance!


Solution

  • Thanks for your advice, @geoand and @zforgo:

    None of those mappers have registered, because ExceptionFeature is not a registered extension. Add jakarta.ws.rs.ext.Provider annotation to ExceptionFeature class.

    zforgo

    You need to add an empty META-INF/beans.xml in src/main/resources of the runtime module.

    geoand

    The beans were not properly registered. Combining your solutions solved the issue. Everything works fine now!

    Thank you for your help!