I have a couple of EJBs that are called from a jax-rs web service. However, every time I call one of the EJB methods I am intercepting the invocation using an interceptor. This interceptor checks the parameters for an API key and if it is not present or doesnt exist in my database it will throw an exception that I wish to catch in my jax-rs code. However, since my jax-rs class has no knowledge of the possibility of this exception being thrown even though the exception could be a checked exception, what would be the best practice here?
I figured out that throwing an unchecked exception would be the best. I then use an exception mapper to catch the exception and handle it.
https://docs.oracle.com/javaee/6/api/javax/ws/rs/ext/ExceptionMapper.html
The only thing that's left is to suppress the exception output to the log files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With