How to block further ServletContextListeners from running if exception is thrown in one of them?

15 Views Asked by At

If I have multiple SerlvetContextListeners in my web.xml (they run in-order per the spec) how can I stop further listeners from running if the previous one throws an exception?

For example:

<listener>
    <listener-class>ListenerA</listener-class>
</listener>
<listener>
    <listener-class>ListenerB</listener-class>
</listener>
<listener>
    <listener-class>ListenerC</listener-class>
</listener>

I want ListenerC to not run at all if ListenerB ends up throwing an exception (which will block the whole application from being deployed anyway).

Is there a way to configure this behavior?

0

There are 0 best solutions below