A ServletContextListener
object registered in a deployment descriptor is not managed by Spring, it is managed by the Servlet Container. As such, Spring has no business injecting any bean into it.
The rule of thumb is, if you have an @Autowired
field target and it is null
, Spring was not involved. Spring will throw all sorts of exceptions if it can't resolve the @Autowired
target.
There are workarounds: