You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using opentelemetry-spring-boot-starter version 2.13.1 in a Spring Boot project( v2.7.18 ), and encountered an issue where the container fails to start due to a NullPointerException during the initialization of a custom filter, which is extend OncePerRequestFilter. The error message indicates that the filter failed because of a null logger reference: java.lang.NullPointerException: Cannot invoke "org.apache.commons.logging.Log.isDebugEnabled()" because "this.logger" is null #011at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:241) #011at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:244) #011at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:101) #011at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3867) #011at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4486) #011at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) #011at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) #011at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) #011at java.base/java.util.concurrent.FutureTask.run(Unknown Source) #011at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) #011at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) #011at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749) #011at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:721) #011at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) #011at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) #011at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) #011at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
After analyzing the stack trace, I found that the root cause is related to Spring AOP using CGLIB proxy generation for this class. Specifically, this class extends OncePerRequestFilter, which contains methods defined as final. CGLIB proxy cannot proxy final methods, causing the proxy generation to fail and ultimately resulting in the NullPointerException.
Add that, for historical reasons, my spring-boot project has a global configuration, proxy-target-class: true, so I don't have a way to implement the interface to get my custom filter to use the JDK proxy for AOP.
Steps to Reproduce:
Create a Spring Boot project and include the opentelemetry-spring-boot-starter dependency (version 2.13.1).
Implement a custom filter that extends OncePerRequestFilter (e.g., PreFlowControlFilter).
Start the application.
Observe the NullPointerException during filter initialization.
Expected Behavior:
OpenTelemetry should handle proxying of OncePerRequestFilter or other similar classes without causing any issues due to final methods. If necessary, a different approach (e.g., using JDK dynamic proxies) could be considered for such classes.
Current Behavior:
The container fails to start, and the proxy generation fails due to the presence of final methods in the parent class, resulting in a NullPointerException.
Possible Solutions:
Consider using JDK proxies (interface-based) rather than CGLIB proxies for classes like OncePerRequestFilter where methods are final.
Or provide an annotation so that Opentelmetry does not enhance the methods in this class.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Description:
I'm using opentelemetry-spring-boot-starter version 2.13.1 in a Spring Boot project( v2.7.18 ), and encountered an issue where the container fails to start due to a NullPointerException during the initialization of a custom filter, which is extend OncePerRequestFilter. The error message indicates that the filter failed because of a null logger reference:
java.lang.NullPointerException: Cannot invoke "org.apache.commons.logging.Log.isDebugEnabled()" because "this.logger" is null #011at org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:241) #011at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:244) #011at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:101) #011at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3867) #011at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4486) #011at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) #011at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) #011at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) #011at java.base/java.util.concurrent.FutureTask.run(Unknown Source) #011at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) #011at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source) #011at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749) #011at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:721) #011at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) #011at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) #011at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) #011at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
After analyzing the stack trace, I found that the root cause is related to Spring AOP using CGLIB proxy generation for this class. Specifically, this class extends OncePerRequestFilter, which contains methods defined as final. CGLIB proxy cannot proxy final methods, causing the proxy generation to fail and ultimately resulting in the NullPointerException.
Add that, for historical reasons, my spring-boot project has a global configuration, proxy-target-class: true, so I don't have a way to implement the interface to get my custom filter to use the JDK proxy for AOP.
Steps to Reproduce:
Create a Spring Boot project and include the opentelemetry-spring-boot-starter dependency (version 2.13.1).
Implement a custom filter that extends OncePerRequestFilter (e.g., PreFlowControlFilter).
Start the application.
Observe the NullPointerException during filter initialization.
Expected Behavior:
OpenTelemetry should handle proxying of OncePerRequestFilter or other similar classes without causing any issues due to final methods. If necessary, a different approach (e.g., using JDK dynamic proxies) could be considered for such classes.
Current Behavior:
The container fails to start, and the proxy generation fails due to the presence of final methods in the parent class, resulting in a NullPointerException.
Possible Solutions:
Consider using JDK proxies (interface-based) rather than CGLIB proxies for classes like OncePerRequestFilter where methods are final.
Or provide an annotation so that Opentelmetry does not enhance the methods in this class.
Beta Was this translation helpful? Give feedback.
All reactions