Skip navigation.

Why ServletContext.getAttribute(Bayeux.ATTRIBUTE) returns null ?

The command

ServletContext.getAttribute(Bayeux.ATTRIBUTE)

returns null when it is run before the CometD servlet has had the chance to put the Bayeux object into the servlet (application) context.

This page explains how to use the load-on-startup element in web.xml to specify the order of initialization of the CometD servlet and of your code.