1 2 Previous Next 16 Replies Latest reply on Jan 28, 2008 6:59 AM by alessandrolt

    Exceptions ending conversations

    alessandrolt

      Hi !

      I'm using exception handling (by annotation and / or pages.xml) of Seam, but when an exception is launched, the classes that are in long-running conversation are discarded.

      Why this happens?

      
      /*
       * Exception class
       */
      @Redirect(viewId="/module/anypage.xhtml", message="Unexpected error")
      public class NoSelectionException extends RuntimeException{
      
      
       private static final String MESSAGE = "Nenhum dado foi selecionado";
       private String keyDefault = "error.nenhumDadoSelecionado";
      
       private ArrayList keys = new ArrayList();
      
      
       public NoSelectionException ()
       {
       super(MESSAGE);
      
       }
      
       //more codes
       ....
      
      
      
      /*
       * Service class
       */
      
      @Name("paService")
      @AutoCreate
      public class PaService {
      
       public String delete(List<Pa> pasSelecteds) {
      
       if (pasSelecteds == null || pasSelecteds.size() == 0)
       throw new NoSelectionException();
      
       paRepository.removePas(pasSelecteds);
      
       return "exibir";
       }
      
      }


        • 1. Re: Exceptions ending conversations
          alessandrolt

          Appear now this message in console:
          [Manager] destroying conversation with garbage lock





          • 2. Re: Exceptions ending conversations
            alessandrolt

            The error in console have serverity FATAL:

            18:14:58,741 FATAL [application] br.com.siq.eqm.exception.NoSelectionException

            ... does it make any sense with end of conversation?

            • 3. Re: Exceptions ending conversations
              alessandrolt

              More information:
              This behavior is not repeated each time. In most cases occurs in Internet Explorer and some in Firefox.

              Seam FAQ wrote:
              http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamProblemsFAQ

              "I've configured Seam's exception handling, but it doesn't always work

              If the exception is thrown early enough in the page rendering process, Seam is able to handle the exception, however, it doesn't work when the page is rendered partially. This occurs because once the response has started to be written, you can't then do a redirect. "


              I'm use RichFaces (but no use ajax) and trinidad:datatable (no ajax too). These libraries may be causing this problem?

              • 4. Re: Exceptions ending conversations
                alessandrolt

                Someone?

                :(

                • 5. Re: Exceptions ending conversations
                  alessandrolt

                  Ainda não consegui resolver o problema.
                  Alguém sabe uma trick?

                  • 6. Re: Exceptions ending conversations
                    alessandrolt

                    Sorry:

                    Still unable to solve the problem.
                    Someone knows a trick?

                    • 7. Re: Exceptions ending conversations
                      pmuir

                      How are you determining the conversation is discarded?

                      • 8. Re: Exceptions ending conversations
                        alessandrolt

                        Hi Pete,

                        Once that occurs any exception, accessing a page that used a component of the conversation, the fields appear clean.

                        If you look at debug.seam, yet this conversation there, but without objects
                        Then the message appears on the console:
                        [Manager] destroying conversation with garbage lock: # 12

                        ... 12 is conversationId. After that, the conversation also disappears from debug.seam and I am redirected to a page set up on no-conversation-view-id.

                        • 9. Re: Exceptions ending conversations
                          pmuir

                          The conversation shouldn't end on exception, unlesss you tell it to.

                          The destroy occurs due to the conversation timeout.

                          Not really sure what to advise, if you track this down further, post back.

                          • 10. Re: Exceptions ending conversations
                            kahliburke

                            It looks like your exception is defined to be a RuntimeException. Is your PaService a stateful session bean? RuntimeExceptions cause the component instance to be removed from the conversation by the RemoveInterceptor, if you are using a SFSB. I believe this is to stay consistent with the J2EE specs, because it is assumed that an uncaught RuntimeException means that the bean is now in an undefined state.

                            If you don't want a RuntimeException to cause this behavior, you need to annotate your exception class with @ApplicationException.

                            Let me know if this solves the issue or if it's something else.

                            Kahli Burke

                            • 11. Re: Exceptions ending conversations
                              alessandrolt

                              The error remains, even with JavaBeans, @ApplicationContext, RuntimeException or Exceptions.
                              Have reproduce this Error in the example "Booking".

                              Please follow these steps:

                              1) Change the method bookHotel() of HotelBookingAction.

                              
                               public void bookHotel() throws Exception
                               {
                               /* booking = new Booking(hotel, user);
                               Calendar calendar = Calendar.getInstance();
                               booking.setCheckinDate( calendar.getTime() );
                               calendar.add(Calendar.DAY_OF_MONTH, 1);
                               booking.setCheckoutDate( calendar.getTime() ); */
                              
                               throw new Exception("Test Error Handler");
                               }
                              
                              


                              2) Change the HotelBooking interface:

                              public void bookHotel() throws Exception;
                              


                              3)Insert in pages.xml:

                               <exception class="java.lang.Exception">
                               <redirect view-id="/main.xhtml">
                               <message severity="error">Test Handle Error Message</message>
                               </redirect>
                               </exception>
                              



                              Now, start seam-booking and choose a hotel. Click in "Book Hotel" button.
                              The exception will redirect to main.xhtml. In the Firefox and IE7 (from w. Vista), the result is not the same (In IE7 does not appear whenever the error message).

                              Select some hotels, click "Book Hotel" and switch workspaces.

                              See. The workpaces exists but the hotels not ("The conversation ended, timed out or was processing another request"). But it is not timed out.

                              I think actually there is a Bug in dealing with the exceptions Seam.

                              It is very important exception handler of Seam without finish the conversation.

                              Can anyone confirm this?

                              Thanks

                              • 12. Re: Exceptions ending conversations
                                alessandrolt

                                 

                                alessandrolt wrote:

                                The error remains, even with JavaBeans, @ApplicationContext, RuntimeException or Exceptions....


                                ... @ApplicationException




                                • 13. Re: Exceptions ending conversations
                                  alessandrolt
                                  • 14. Re: Exceptions ending conversations
                                    alessandrolt

                                    When this occurs, the ConversationEntry is lock and never unlocked,until they are discarded. Maybe that is the problem ...

                                    I found this in JIRA:
                                    Http://jira.jboss.org/jira/browse/JBSEAM-537

                                    This can be the cause?
                                    How to solve?

                                    1 2 Previous Next