This content has been marked as final.
Show 5 replies
-
1. Re: How to send exceptions through email
danielc.roth May 28, 2008 9:15 AM (in response to bogdanminciu.bogdan.minciu.yahoo.com)Just some copy-paste I use during devel:
pages.xml.
<exception> <end-conversation /> <redirect view-id="/error.xhtml"> </exception> <page view-id="/error.xhtml" login-required="false"> <action execute="#{error.sendMail}" /> </page>
@Name("error") @Scope(ScopeType.EVENT) public class ErrorAction implements Serializable { @In(value = "org.jboss.seam.handledException") private Exception e; @In private MailService mailService; public void sendMail() { mailService.sendErrorMail(e, "exception"); } }
Mailservice thingy
public void sendErrorMail(Throwable throwable, String message) { StringBuffer err = new StringBuffer(); if (throwable != null) { err.append(throwable.getLocalizedMessage()).append("\n"); err.append(throwable.getMessage()).append("\n"); for (StackTraceElement elem : throwable.getStackTrace()) { err.append(elem.getFileName()).append(":").append(elem.getLineNumber()).append(":").append(elem.getClassName()).append(":").append( elem.getMethodName()).append("\n"); } } Contexts.getEventContext().set("subject", message); Contexts.getEventContext().set("body", err.toString()); Contexts.getEventContext().set("to", developer); renderer.render("/mail/error.xhtml"); }
It just prints the stack in a way I like to see it. I guess you you just do something like
StringWriter content = new StringWriter(); throwable.printStackTrace(new PrintWriter(content)); String body = content.getBuffer().toString();
to get the ordinary stacktrace.
-
2. Re: How to send exceptions through email
tom_goring May 28, 2008 10:05 AM (in response to bogdanminciu.bogdan.minciu.yahoo.com)You can set Log4J to send exceptions to an email address... but this is generic (i.e. it won't do the debug.xhtml stuff)
-
3. Re: How to send exceptions through email
bogdanminciu.bogdan.minciu.yahoo.com May 30, 2008 4:35 PM (in response to bogdanminciu.bogdan.minciu.yahoo.com)Thank you for the reply Daniel. This is good starting point for what I need.
-
4. Re: How to send exceptions through email
indusukumar Feb 4, 2009 12:24 PM (in response to bogdanminciu.bogdan.minciu.yahoo.com)Hi,
Currently i am in need to send an email notification on complete of some event in my application, can you help me with the steps to configure for it in Seam.
Thanks in advance...
Indu
-
5. Re: How to send exceptions through email
daniele4 Jun 11, 2009 6:52 PM (in response to bogdanminciu.bogdan.minciu.yahoo.com)Hi daniel,
i am a newbie with seam, i dont have sendErrorMail method on class MailService!
What's wrong?thankyou in advance