Я пытаюсь получить sessionId внутри applicationListener impl. Он выдает исключение NULLPointerException в session.getId(). Интересно, почему он получил исключение. Сеанс создан, но не может получить доступ к другим атрибутам. Ниже мой код.Inject httpSession весной ApplicationListener
@Component
public class MyEventListener implements ApplicationListener<MyEvent> {
@Autowired
HttpSession session;
@Override
public void onApplicationEvent(final QuotePricingEvent quoteEvent) {
LOGGER.error("Session id: {}, userid: {}", session.getId());
}
}
Редактировать
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
servletContext.addListener(RequestContextListener.class);
}
Предоставьте [mcve] и полную трассировку стека. –