Skip to content

Commit

Permalink
Fix java.lang.ClassNotFoundException: org.springframework.web.servlet…
Browse files Browse the repository at this point in the history
….HandlerExceptionResolver in Spring Boot Servlet mode without WebMVC (#3333)

* Wrap SentryExceptionResolver auto config

* changelog
  • Loading branch information
adinauer authored Apr 8, 2024
1 parent 60eb716 commit e7d4adc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,21 @@ public FilterRegistrationBean<SentryTracingFilter> 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());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,21 @@ public FilterRegistrationBean<SentryTracingFilter> 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());
}
}
}

Expand Down

0 comments on commit e7d4adc

Please sign in to comment.