4 Replies Latest reply on Nov 29, 2006 10:30 AM by rbz285

    Debug page intercepts handled exceptions in 1.1

    rbz285

      I've just upgraded from 1.0.1.GA to 1.1.0.CR1

      In my app I have a JSF page calling a stateful seam bean which then calls another stateless seam bean. The second bean can throw an exception which is caught and handled by the first, which then shows a faces message. However, in 1.1 the seam debug page is shown instead.

      If I turn off debug in components.xml it works again but I then can't look at the debug page at all.

      From looking at the code the debug page is triggered by the ExceptionInterceptor which has the code:

       boolean outermost = invocation.getContextData().get("org.jboss.seam.outermostExceptionInterceptor")==null;
       invocation.getContextData().put("org.jboss.seam.outermostExceptionInterceptor", true);
       try
       {
       return invocation.proceed();
       }
       catch (Exception e)
       {
       if ( outermost && FacesContext.getCurrentInstance()!=null )
       {
       return Exceptions.instance().handle(e);
       }
       else
       {
       throw e;
       }
       }
      


      when I debugged it I found that the contextData on the invocationContext was different on the call to the second bean than on the initial JSF call to the first bean so the outermost flag was true in both cases.

      Does anybody else have it working doing a similar thing ? given all the other messages here I wouldn't be surprised if its a config issue

      (I haven't used exceptions.xml at all yet)

      I'm using Seam 1.1.0.CR1, JBoss 4.0.5.GA, Facelets 1.1.11, myFaces 1.1.4, ajax4jsf 1.0.3

        • 1. Re: Debug page intercepts handled exceptions in 1.1
          gavin.king

           

          when I debugged it I found that the contextData on the invocationContext was different on the call to the second bean than on the initial JSF call to the first bean so the outermost flag was true in both cases.


          Ah. Good point. That's a bug.

          http://jira.jboss.com/jira/browse/JBSEAM-534

          • 2. Re: Debug page intercepts handled exceptions in 1.1
            rbz285

            thanks, I've just tried the fix using the 20061129 nightly build that has the change in it but it doesn't work for me, it still shows the debug page

            I've checked that the download includes the source change

             static ThreadLocal marker = new ThreadLocal();
            
             @AroundInvoke
             public Object handleExceptions(InvocationContext invocation) throws Exception
             {
             boolean outermost = marker.get() == null;
             marker.set(this);
             try {
             return invocation.proceed();
             } catch (Exception e) {
             if (outermost && FacesContext.getCurrentInstance()!=null) {
             return Exceptions.instance().handle(e);
             } else {
             throw e;
             }
             } finally {
             marker.remove();
             }
             }
            


            I reckon it doesn't work for me because my first bean actually calls 2 different methods on my second bean and so the above code calls marker.remove() after the first call to the second bean, hence the next call is treated as the outermost.

            It would probably be better to only bother with the exception logic if its actually going to be used, something like:

             @AroundInvoke
             public Object handleExceptions(InvocationContext invocation) throws Exception
             {
             boolean outermost = marker.get() == null;
             if (outermost) {
             marker.set(this);
             try {
             return invocation.proceed();
             } catch (Exception e) {
             if (FacesContext.getCurrentInstance()!=null) {
             return Exceptions.instance().handle(e);
             } else {
             throw e;
             }
             } finally {
             marker.remove();
             }
             }
             else {
             return invocation.proceed();
             }
             }
            


            what do you reckon ?

            • 3. Re: Debug page intercepts handled exceptions in 1.1
              gavin.king

              Try again, I just fixed the fix.

              • 4. Re: Debug page intercepts handled exceptions in 1.1
                rbz285

                it works for me now

                thanks