seamseam2servletexception

How to add custom filters in JBoss Seam


I am new to JBoss Seam. I have been having issues with a small project am working on. The project has some errors and unfortunately for me I cannot find out the exact cause of the errors. I get a javax.servlet.ServletException. Please could someone tell me how to add custom filters so that I would be able to trap errors properly.


Solution

  • If you want to trap all synchronous exceptions happening in Seam, you extend the Exceptions class in Seam.

    @Name("org.jboss.seam.exception.exceptions")
    @Scope(ScopeType.APPLICATION)
    @Install(precedence = Install.APPLICATION)
    @BypassInterceptors
    @Transactional
    public class ExceptionHandler extends Exceptions {
    
        private static final LogProvider log = Logging.getLogProvider(ExceptionHandler.class);
    
        public void handle(Exception ex) throws Exception {
             //Here you can do whatever you want with the exception
             log.error("Exception occurred : " + ex.getMessage());
             super.handle(ex);
        }