0 Replies Latest reply on May 12, 2010 8:19 AM by virendra agarwal

    Exception handling didnot et stack trace

    virendra agarwal Newbie
      Hi I am using seam with jsf.
      My problem is exception handling.
      I have added my exception tags in pages.xml.

      <exception class="java.lang.Exception">
              <redirect view-id="/error.xhtml">
                  <message severity="error">#{messages.unexpected_error</message>
              </redirect>
        </exception>

      When ever exception occurs it is redirected to error page that works fine.
      But i want to capture when ever an exception occurs . I am not concern with the type and where it occurs i need to get print stack trace of the exception when ever it occurs.

      For this i created a class




      `@Name("errorHandler")
      public class ErrorHandlerImpl extends ExceptionHandler {
              
             
              private String stackTrace;
             
              public String getStackTrace() {
                     
                      return stackTrace;
              }

              public void setStackTrace(String stackTrace) {
                      this.stackTrace = stackTrace;
              }

              @Override
              public void handle(Exception e) throws Exception {
                      stackTrace = "jhgvjkhkjhbjkhkj";
                     
                      e.printStackTrace();
                     
              }

              @Override
              public boolean isHandler(Exception e) {
                      return true;
              }
      }`


      I dont know how can i call handle method to get the exception. I am new to seam so tell me how i use this class.
      My error.xhtml page calls stackTrace like this.

      <h1>Error</h1>
              <h:outputText value="#{errorHandler.stackTrace}"></h:outputText>
                      <br></br>
              <h:messages id="errorMessage" styleClass="message"/>
      Please help me how can i get stack trace of the exception.
      Thanks & Regards