3 Replies Latest reply on Jan 24, 2014 4:06 PM by wdfink

    EJB "shutdown exception" is not caught by EJB interceptors

    nmoelholm

      Hi Guys,

       

      This might be "working as designed". However I was a bit surprised of the interceptor precedence here.

       

      Using: JBoss AS 7.2 Final.

       

      I have a "BeanA" that invokes a method on "BeanB" in a @Timeout method. Both beans are EJB session beans.

       

      Upon shutdown of the application server, BeanA receives this exception:

      javax.ejb.EJBException: JBAS014559: Invocation cannot proceed as component is shutting down
      

       

      I hoped that I could write a default EJB  interceptor that catches this exception. But it turns out that the BeanB EJB proxy never get's to call my interceptor - since an internal EJB stack interceptor blows up first....

       

      ( My intention is to perform some internal translation to a typesafe EJBException subclass )

       

      Anyways - is it possible to instruct JBoss AS 7.2 to give application interceptors precedence to system interceptors ? If not - then that would be nice (regarding security concerns...cannot imagine any loopholes here...)

        • 1. Re: EJB "shutdown exception" is not caught by EJB interceptors
          wdfink

          No, the Interceptor has the same lifecycle as the Bean itself (from the EJB spec) and get invoked if the bean is invoked. So there is no chance to get this working.

          Only possibility I know is to have a client side interceptor, but this did not work for local invocations.

          • 2. Re: Re: EJB "shutdown exception" is not caught by EJB interceptors
            nmoelholm

            Hi Wolf-Dieter Fink,

             

            Thanks for answering! I understand your point with regards to the EJB specification and the interceptor lifecycle. It makes sense that the interceptor is created and destroyed with the bean instance. But I still don't find the relation to the non-application provided interceptors. Anyways - I am happy to inform you (and others in my situation) that ...

             

            I found a JBoss 7.2 / Wildfly specific solution to this: Container Interceptors.

             

            Documentation can be found here: https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html/Development_Guide/sect…

             

            Using Container Interceptors I can place an "application interceptor" before all the JBoss AS default interceptors (security, tx, cdi, etc).

             

            Unfortunately for me, the following happens: Upon shutdown (ctrl+c) of the server this chain is reduced to exclude my custom Container Interceptor(s). What this means is that... I still cannot intervene.

             

            Anyways - for anybody who just want to intercept security exceptions, tx exceptions etc - Container Interceptors is the way....

             

             

            1 of 1 people found this helpful
            • 3. Re: EJB "shutdown exception" is not caught by EJB interceptors
              wdfink

              Yes you are right, but as you mentioned this will not work as the container will check whether the deployment is in shutdown-state.

               

              BTW you should mark the helpful answers and he thread as asumed answered" to help other find informations.

              1 of 1 people found this helpful