Check for a behavior change on the ServletContextListener interface

A clarification from the Servlet 3.1 specification now does not allow an implementer of the ServletContextListener interface to programmatically configure servlets, filters, or listeners if the ServletContextListener was not declared in the web.xml file or web-fragment.xml file or was not annotated with @WebListener. As a result, any call on the ServletContext interface to perform such programmatic configuration results in an UnsupportedOperationException. This rule flags classes that implement the javax.servlet.ServletContextListener interface and are neither annotated with @WebListener nor are defined as a listener-class in the web.xml file or web-fragment.xml.

The following methods can throw the UnsupportedOperationException:

For more information on these methods see Interface ServletContext.

For more information on Servlet 3.1 behavior changes, see the following resource: Servlet 3.1 behavior changes.