NullPointerException in GenericFilterBean on Spring Boot application start after adding a custom filter that extends OncePerRequestFilter.
Here is the stack trace:
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.commons.logging.Log.isDebugEnabled()" because "this.logger" is null at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:241)
We are using Spring Boot version 2.7.6.
Any solution for this issue?
I had the same problem with the Spring Boot app and Micrometer. I realized that you cannot use Micrometer annotations whenever you want. It happens because of the Proxy mechanism. JDK Dynamic Proxy can only create proxy if the target class implements at least 1 interface whereas CGLIB Proxy has no such limitation and is able to create proxy as long as the target class / method is non-final. This is important because it will help us understand why Spring AOP will not work on OncePerRequestFilter class.
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