Commit 950eafe9 authored by Andy Wilkinson's avatar Andy Wilkinson

Improve diagnostics when ServletContext.addListener fails

The various servlet containers that we support vary in the quality
of their diagnostics when ServletContext.addListener fails. To make
problem diagnosis easier, this commit ensures that the toString of the
the listener that was being added is included in the exception that's
thrown when a failure occurs.

Closes gh-2197
parent 5c67e6f1
......@@ -105,8 +105,14 @@ public class ServletListenerRegistrationBean<T extends EventListener> extends
logger.info("Listener " + this.listener + " was not registered (disabled)");
return;
}
try {
servletContext.addListener(this.listener);
}
catch (RuntimeException ex) {
throw new IllegalStateException("Failed to add listener '" + this.listener
+ "' to servlet context", ex);
}
}
public T getListener() {
return this.listener;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment