diff --git a/CHANGELOG.md b/CHANGELOG.md index e140b334b3..f16886a00a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Fixes - Fixed default deadline timeout to 30s instead of 300s ([#3322](https://github.com/getsentry/sentry-java/pull/3322)) +- Fixed `Fix java.lang.ClassNotFoundException: org.springframework.web.servlet.HandlerExceptionResolver` in Spring Boot Servlet mode without WebMVC ([#3333](https://github.com/getsentry/sentry-java/pull/3333)) ## 7.6.0 diff --git a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java index fbf3162280..8a55208e21 100644 --- a/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java +++ b/sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java @@ -296,15 +296,21 @@ public FilterRegistrationBean sentryTracingFilter( return filter; } - @Bean - @ConditionalOnMissingBean + /** Wraps exception resolver @Bean because the return type is loaded too early otherwise */ + @Configuration(proxyBeanMethods = false) @ConditionalOnClass(HandlerExceptionResolver.class) - public @NotNull SentryExceptionResolver sentryExceptionResolver( - final @NotNull IHub sentryHub, - final @NotNull TransactionNameProvider transactionNameProvider, - final @NotNull SentryProperties options) { - return new SentryExceptionResolver( - sentryHub, transactionNameProvider, options.getExceptionResolverOrder()); + @Open + static class SentryExceptionResolverConfigurationWrapper { + + @Bean + @ConditionalOnMissingBean + public @NotNull SentryExceptionResolver sentryExceptionResolver( + final @NotNull IHub sentryHub, + final @NotNull TransactionNameProvider transactionNameProvider, + final @NotNull SentryProperties options) { + return new SentryExceptionResolver( + sentryHub, transactionNameProvider, options.getExceptionResolverOrder()); + } } } diff --git a/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java b/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java index edbfee271d..ac2fd57e98 100644 --- a/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java +++ b/sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java @@ -294,15 +294,21 @@ public FilterRegistrationBean sentryTracingFilter( return filter; } - @Bean - @ConditionalOnMissingBean + /** Wraps exception resolver @Bean because the return type is loaded too early otherwise */ + @Configuration(proxyBeanMethods = false) @ConditionalOnClass(HandlerExceptionResolver.class) - public @NotNull SentryExceptionResolver sentryExceptionResolver( - final @NotNull IHub sentryHub, - final @NotNull TransactionNameProvider transactionNameProvider, - final @NotNull SentryProperties options) { - return new SentryExceptionResolver( - sentryHub, transactionNameProvider, options.getExceptionResolverOrder()); + @Open + static class SentryExceptionResolverConfigurationWrapper { + + @Bean + @ConditionalOnMissingBean + public @NotNull SentryExceptionResolver sentryExceptionResolver( + final @NotNull IHub sentryHub, + final @NotNull TransactionNameProvider transactionNameProvider, + final @NotNull SentryProperties options) { + return new SentryExceptionResolver( + sentryHub, transactionNameProvider, options.getExceptionResolverOrder()); + } } }