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
We noticed this issue in our application when attempting to upgrade from 2.3.5.RELEASE to 2.4.2. In our case, the arguments passed to the class annotated with @WebListener are @Component classes, but in the example repo I was able to reproduce the error with or without that annotation. Spring starts just fine when you remove the argument to the constructor.
I configured the app to use the Spring Boot 2.5 snapshot and got the same error, for what it's worth.
The text was updated successfully, but these errors were encountered:
I'm a little surprised that @WebListener constructor injection worked in 2.4, it was probably by accident rather than design. @bencalegari If you change your SessionListener class so that it's annotated with @Component and not @WebListener do things work as expected? All HttpSessionListener beans in the context should be automatically added to the servlet container.
Thanks! That fixed it, both in the sample app and ours. Is there a reason why constructor injection in @WebListeners should've been avoided at the outset?
It's a requirement of the Servlet spec that listeners, filters, and servlets must have a zero-args constructor. This applies whether they're registered via web.xml or the various annotations.
Spring Boot Version: 2.4.2
Here's an abbreviated
./gradlew bootRun
log from a sample app I created to replicate the issue:You can find the entirety of the log in this Github action from the repo.
We noticed this issue in our application when attempting to upgrade from 2.3.5.RELEASE to 2.4.2. In our case, the arguments passed to the class annotated with
@WebListener
are@Component
classes, but in the example repo I was able to reproduce the error with or without that annotation. Spring starts just fine when you remove the argument to the constructor.I configured the app to use the Spring Boot 2.5 snapshot and got the same error, for what it's worth.
The text was updated successfully, but these errors were encountered: