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
This commit is contained in:
parent
5c67e6f141
commit
950eafe9cc
|
@ -105,7 +105,13 @@ public class ServletListenerRegistrationBean<T extends EventListener> extends
|
|||
logger.info("Listener " + this.listener + " was not registered (disabled)");
|
||||
return;
|
||||
}
|
||||
servletContext.addListener(this.listener);
|
||||
try {
|
||||
servletContext.addListener(this.listener);
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
throw new IllegalStateException("Failed to add listener '" + this.listener
|
||||
+ "' to servlet context", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public T getListener() {
|
||||
|
|
Loading…
Reference in New Issue