Sentry - Java Spring Implementation

Hi everybody!

I’m new to Sentry framework and are deploying my first app on production with Sentry tracking errors.

My app is a Java SpringBoot Service, and following these instructions

1° I added these dependency to pom.xml (Maven build)

io.sentry sentry-spring 1.7.23

2° Create that Configutation Class

public class SentryConfig {
public HandlerExceptionResolver sentryExceptionResolver() {
return new io.sentry.spring.SentryExceptionResolver();

And it’s working for controller calls well, as when front-end call a path of my service and something break throwing a Excpetion, Sentry automatic capture that.

However, i need some configuration to internal Exception (As a Scheduled job with Quartz) also be captured by Sentry automatic, someone has any ideia of how to do that?

What i did for these scenario today is a manually Capture, using Sentry static API i call in EVERY try{}catch{} the Sentry.capture(Exception).

Hoped has explained clear rs
Tks! o/

What do you mean by every try catch? Wouldn’t it be a single try/catch at the root of the job. Whatever entry point method Quartz invokes?
The exception will bubble up and the stack trace reported so no information will be missed.

Unless you need to handle the exception and carry on, in which case there’s no other way but to manually capture the exception.

I don’t know Quartz but it’s possible it has a global error handler hook which gets invoked if the tasks throws. In that case you could just add a handler that captures the exception with Sentry.captureException.

1 Like

Tks Bruno for reply,

Man u are right… by “root of the job” i wonder a better way to handle exceptions on my code…

I used to setting try/catches everywhere and by this pactice i had this ‘problem’, searching for a better way i found this article

Who are using Sentry and has the same doubt like me, read this article!
Tks buddy, cia

1 Like