This content has been marked as final.
Show 3 replies
-
1. Re: Manager Exception with page.xml
cash1981 Aug 3, 2010 3:20 AM (in response to daniele4)The correct way is to extends Seam's ExceptionHandler.
From this class you can get the stacktrace, and call an event that will either log or send the stacktrace as email.
Pseudo code:
@Name("org.jboss.seam.exception.ExcetionHandler") @Transactional @Bypassinterceptors public class MyExceptionHandler extends ExceptionHandler { public void handle(Exception e) { StringWriter writer = new StringWriter(); e.printStacktrace(writer); Events.instance().raiseEvent("ExceptionOccurred", writer.toString()); //This event will trigger an email to be sendt with the stacktrace } }
The above code wont work as is, you will need to rewrite it slightly
-
2. Re: Manager Exception with page.xml
daniele4 Aug 3, 2010 8:01 AM (in response to daniele4)good solution!!
thanks
-
3. Re: Manager Exception with page.xml
cash1981 Aug 3, 2010 8:10 AM (in response to daniele4)Ok so this is how we do it, you can basically copy/paste this
import java.io.PrintWriter; import java.io.StringWriter; import org.jboss.seam.Component; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Install; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.intercept.BypassInterceptors; import org.jboss.seam.core.Events; import org.jboss.seam.exception.Exceptions; @Name("org.jboss.seam.exception.exceptions") @Scope(ScopeType.APPLICATION) @Install(precedence = Install.APPLICATION) @BypassInterceptors public class ExceptionHandler extends Exceptions { public void handle(Exception ex) throws Exception { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); //Put the stracktrace in StringWriter Events.instance().raiseAsynchronousEvent(SystemlogListener.EVENT_ADD_DETAILED_SYSTEMLOG, ex.getMessage()),sw.toString()); super.handle(ex); } }