← All platforms

Servlet error tracking

A servlet container handles the request. Keep somewhere to investigate the exception. The Sentry Servlet integration sends its reports to your Telebugs server.

~/hoofnotes  nvim build.gradle src/main/java/com/hoofnotes/SentryInitializer.java src/main/resources/META-INF/services/javax.servlet.ServletContainerInitializer
dependencies {
implementation 'io.sentry:sentry-servlet:8.55.0'
}
package com.hoofnotes;
import io.sentry.Sentry;
import java.util.Set;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
public final class SentryInitializer implements ServletContainerInitializer {
public void onStartup(Set<Class<?>> classes, ServletContext context) {
Sentry.init(options -> {
// Copy the complete DSN, key and path included.
options.setDsn("YOUR_TELEBUGS_DSN");
});
}
}
com.hoofnotes.SentryInitializer
~/hoofnotes  ./gradlew war

Space pauses or resumes. R replays. Escape shows the complete setup.

Hang on, I already use Sentry

Keep sentry-servlet and change its destination to your Telebugs DSN. Your error reports stay on your server. You don’t need a Sentry account.

Does this need Spring?

No. The Servlet integration can add request context inside a servlet container without Spring. Your application can report caught exceptions through the Java SDK too.

What about Jakarta applications?

Use the SDK artifact matching your servlet API. The example shows javax.servlet; Jakarta applications have a corresponding integration. Both send Java error reports to Telebugs.