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!
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!
Share Improve this question asked Feb 17 at 17:40 Laurent_LDNRLaurent_LDNR 12 bronze badges New contributor Laurent_LDNR is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 5 |1 Answer
Reset to default 0Thanks for your advice, @geoand and @zfo:
None of those mappers have registered, because
ExceptionFeature
is not a registered extension. Addjakarta.ws.rs.ext.Provider
annotation toExceptionFeature
class.– zfo
You need to add an empty
META-INF/beans.xml
insrc/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!
ExceptionFeature
is not a registered extension. Addjakarta.ws.rs.ext.Provider
annotation toExceptionFeature
class. – zfo Commented 2 days agoMETA-INF/beans.xml
insrc/main/resources
of theruntime
module. – geoand Commented 2 days ago