Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > email from catch or exception

Reply
Thread Tools

email from catch or exception

 
 
Eric Sosman
Guest
Posts: n/a
 
      12-12-2013
On 12/11/2013 6:23 PM, RVic wrote:
> On Wednesday, December 11, 2013 5:55:34 PM UTC-5, RVic wrote:
>> Is anyone aware of a public domain package that can email you on an error, include the stack trace or log, whenever an exception occurs? Thank you, RVic

>
> Looking to send an email on exceptions that are caught, and a general one for those that are uncaught.
>
> I dont mind if there are a ton of emails!


I honestly do not know how many exceptions are thrown each
second in a "typical" Java program. As I said in another post
I think you'd have to modify the JVM to find out -- or maybe
you could use something in java.lang.instrument, a package I've
never had occasion to unwrap. Perhaps you should loosen that
ribbon a bit before writing "I want ALL of them!" on your
Christmas list.

But even if it's only one per second, you'll get 86400 per
day. Can you read 86400 E-mails in one day? Can you find the
four "different" stack traces among those 86400? Remember: You
have ONE second to make up your mind about each of them, if you
don't want to fall behind! Less, if you're monitoring more than
one Java environment ... Try this experiment: Turn off all your
spam filters, and opt out of any that your ISP offers, and tell
us how smoothly you deal with the onslaught.

Another little matter: At a rate of >= 1 E-mail/second, many
mail servers will say "Spammer!" and refuse to cooperate. What
are the chances that any of the "interesting" E-mails will be
among those that get through before the boom is lowered?

If you're in a position to write `catch' blocks to separate
the "possibly interesting" from "certainly boring" exceptions,
java.util.logging.Handler has sufficient hooks to spew info to
an agent that will E-mail it. But ALL exceptions!? I can't think
of any way (even in principle) to do that with a stock JVM, and
I can't imagine that you'd get anything usable out of it.

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)d
 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      12-12-2013
On 12/11/2013 9:09 PM, Eric Sosman wrote:
> On 12/11/2013 6:23 PM, RVic wrote:
>> On Wednesday, December 11, 2013 5:55:34 PM UTC-5, RVic wrote:
>>> Is anyone aware of a public domain package that can email you on an
>>> error, include the stack trace or log, whenever an exception occurs?
>>> Thank you, RVic

>>
>> Looking to send an email on exceptions that are caught, and a general
>> one for those that are uncaught.
>>
>> I dont mind if there are a ton of emails!

>
> I honestly do not know how many exceptions are thrown each
> second in a "typical" Java program. [...]


.... but I found a twelve-year-old paper about optimizing both
the exceptional and unexceptional execution paths ("A Study of
Exception Handling and Its Dynamic Optimization in Java," by
Ogasawara, Komatsu, and Nakatani). It contains a table counting
how many exceptions are thrown by various programs. Some excerpts:

- Web browser opening one (2001-vintage) page: 2,892 exceptions
- MP3 player starting and loading one file: 8,205 exceptions
- Parse one XML file (size? complexity?): 17,640 exceptions
- One program in SPECjvm98 (now obsolete): 242,318 exceptions

Now: Speaking slowly, distinctly, and directly into the
carnation in my buttonhole, explain once again that you "dont
mind if there are a ton of emails."

--
Eric Sosman
(E-Mail Removed)d
 
Reply With Quote
 
 
 
 
Arved Sandstrom
Guest
Posts: n/a
 
      12-13-2013
On 12/11/2013 08:08 PM, Arne Vajh°j wrote:
> On 12/11/2013 6:13 PM, Eric Sosman wrote:
>> On 12/11/2013 5:55 PM, RVic wrote:
>>> Is anyone aware of a public domain package that can email you on an
>>> error, include the stack trace or log, whenever an exception occurs?

>>
>> I think you'd have to modify the JVM itself to do this. But
>> you wouldn't want to: If you got an E-mail for every exception
>> thrown, you'd drown in E-mail.
>>
>> Presumably, what you really want is E-mail about "important"
>> exceptions, and the hard part is clarifying what "important" means.
>> Could you describe your use case in more detail?

>
> In theory exceptions should be for exceptional cases meaning
> no drowning in emails.
>
> I have seen many apps where your concerns are valid though.
>
> Arne
>

It's true that exceptions are for exceptional cases. The Java tutorial
says that:

"An exception is an event, which occurs during the execution of a
program, that disrupts the normal flow of the program's instructions."

However, as you yourself admit, Arne, there are many apps where there
are frequent exceptions. And no small number of these apps are actually
well-designed.

As an example (and this is based on a setup I am familiar with),
consider an ESB app that mediates between 2 systems: A and B. System A
is a source of data for system B, but both are unaware of each other,
and the data must be transformed before it goes into B. The hitch is,
the ESB app has no ability to do more than very simple validation, and
System A has a fair bit of bad data, because of human data entry and
configuration reasons [1]. Hence, System B must validate (because it
knows what it can accept), and this works OK.

The validation errors must come back to the ESB app, since the ESB app
is the controlling intelligence. They come back as SOAP faults (Java
runtime exceptions), which is appropriate.

Furthermore, the ESB app polls System A, and communicates with System B
using SOAP, every few minutes (this interval being configurable but
dictated by business requirements).

So the first few months we were getting a few dozen SOAP faults every
few minutes, so say about 500-1000 every hour, or 10-20 thousand a day.

Thing is, 99 percent of those 10-20 thousand SOAP faults were for the
same few dozen bad data entries in System A. Sending an email for each
of those would have overwhelmed the human recipients. We recognized that
a separate ESB job that ran every 24 hours (and effectively called the
same intermediary logic) would capture all the problems, and it could
send out a *single* email that provided a summary of the bad data in
system A (and why it was bad).

Point being, email notification on errors (as with logging errors to
file etc) are almost always going to a human being [2]. As such, the
urgency of an error dictates whether a notification should be sent at
all, how often an email should be sent, who gets it (human or system),
the nature of the email content (summary or single event), etc etc.

To wit, for a large percentage of apps I think an "email per exception"
strategy will lead to drowning in emails. And you can Splunk or
grep|uniq|cut|cat|paste all that to your hearts's content...essentially
wasting your time to do what the reporting systems could have done in
the first place.

AHS

1. The fixes for which, in a unionized and bureaucratic environment, are
not simple.

2. I suppose you could send a stringified object reference to a CORBA
client...
--
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      12-14-2013
On 12/13/2013 11:44 AM, Arved Sandstrom wrote:
> On 12/11/2013 08:08 PM, Arne Vajh°j wrote:
>> On 12/11/2013 6:13 PM, Eric Sosman wrote:
>>> On 12/11/2013 5:55 PM, RVic wrote:
>>>> Is anyone aware of a public domain package that can email you on an
>>>> error, include the stack trace or log, whenever an exception occurs?
>>>
>>> I think you'd have to modify the JVM itself to do this. But
>>> you wouldn't want to: If you got an E-mail for every exception
>>> thrown, you'd drown in E-mail.
>>>
>>> Presumably, what you really want is E-mail about "important"
>>> exceptions, and the hard part is clarifying what "important" means.
>>> Could you describe your use case in more detail?

>>
>> In theory exceptions should be for exceptional cases meaning
>> no drowning in emails.
>>
>> I have seen many apps where your concerns are valid though.
>>
>> Arne
>>

> It's true that exceptions are for exceptional cases. The Java tutorial
> says that:
>
> "An exception is an event, which occurs during the execution of a
> program, that disrupts the normal flow of the program's instructions."
>
> However, as you yourself admit, Arne, there are many apps where there
> are frequent exceptions. And no small number of these apps are actually
> well-designed.
>
> As an example (and this is based on a setup I am familiar with),
> consider an ESB app that mediates between 2 systems: A and B. System A
> is a source of data for system B, but both are unaware of each other,
> and the data must be transformed before it goes into B. The hitch is,
> the ESB app has no ability to do more than very simple validation, and
> System A has a fair bit of bad data, because of human data entry and
> configuration reasons [1]. Hence, System B must validate (because it
> knows what it can accept), and this works OK.
>
> The validation errors must come back to the ESB app, since the ESB app
> is the controlling intelligence. They come back as SOAP faults (Java
> runtime exceptions), which is appropriate.
>
> Furthermore, the ESB app polls System A, and communicates with System B
> using SOAP, every few minutes (this interval being configurable but
> dictated by business requirements).
>
> So the first few months we were getting a few dozen SOAP faults every
> few minutes, so say about 500-1000 every hour, or 10-20 thousand a day.
>
> Thing is, 99 percent of those 10-20 thousand SOAP faults were for the
> same few dozen bad data entries in System A. Sending an email for each
> of those would have overwhelmed the human recipients. We recognized that
> a separate ESB job that ran every 24 hours (and effectively called the
> same intermediary logic) would capture all the problems, and it could
> send out a *single* email that provided a summary of the bad data in
> system A (and why it was bad).
>
> Point being, email notification on errors (as with logging errors to
> file etc) are almost always going to a human being [2]. As such, the
> urgency of an error dictates whether a notification should be sent at
> all, how often an email should be sent, who gets it (human or system),
> the nature of the email content (summary or single event), etc etc.
>
> To wit, for a large percentage of apps I think an "email per exception"
> strategy will lead to drowning in emails. And you can Splunk or
> grep|uniq|cut|cat|paste all that to your hearts's content...essentially
> wasting your time to do what the reporting systems could have done in
> the first place.


Well - I am not convinced that the exception is the right choice
when the data quality is as it is resulting in 10-20 thousand
exceptions per day.

But that type of scenario is seen frequently.

But given the question, then I am not expecting the original
poster to be working on that type of application.

Arne




 
Reply With Quote
 
Arved Sandstrom
Guest
Posts: n/a
 
      12-15-2013
On 12/14/2013 05:36 PM, Arne Vajh°j wrote:
> On 12/13/2013 11:44 AM, Arved Sandstrom wrote:
>> On 12/11/2013 08:08 PM, Arne Vajh°j wrote:
>>> On 12/11/2013 6:13 PM, Eric Sosman wrote:
>>>> On 12/11/2013 5:55 PM, RVic wrote:
>>>>> Is anyone aware of a public domain package that can email you on an
>>>>> error, include the stack trace or log, whenever an exception occurs?
>>>>
>>>> I think you'd have to modify the JVM itself to do this. But
>>>> you wouldn't want to: If you got an E-mail for every exception
>>>> thrown, you'd drown in E-mail.
>>>>
>>>> Presumably, what you really want is E-mail about "important"
>>>> exceptions, and the hard part is clarifying what "important" means.
>>>> Could you describe your use case in more detail?
>>>
>>> In theory exceptions should be for exceptional cases meaning
>>> no drowning in emails.
>>>
>>> I have seen many apps where your concerns are valid though.
>>>
>>> Arne
>>>

>> It's true that exceptions are for exceptional cases. The Java tutorial
>> says that:
>>
>> "An exception is an event, which occurs during the execution of a
>> program, that disrupts the normal flow of the program's instructions."
>>
>> However, as you yourself admit, Arne, there are many apps where there
>> are frequent exceptions. And no small number of these apps are actually
>> well-designed.
>>
>> As an example (and this is based on a setup I am familiar with),
>> consider an ESB app that mediates between 2 systems: A and B. System A
>> is a source of data for system B, but both are unaware of each other,
>> and the data must be transformed before it goes into B. The hitch is,
>> the ESB app has no ability to do more than very simple validation, and
>> System A has a fair bit of bad data, because of human data entry and
>> configuration reasons [1]. Hence, System B must validate (because it
>> knows what it can accept), and this works OK.
>>
>> The validation errors must come back to the ESB app, since the ESB app
>> is the controlling intelligence. They come back as SOAP faults (Java
>> runtime exceptions), which is appropriate.
>>
>> Furthermore, the ESB app polls System A, and communicates with System B
>> using SOAP, every few minutes (this interval being configurable but
>> dictated by business requirements).
>>
>> So the first few months we were getting a few dozen SOAP faults every
>> few minutes, so say about 500-1000 every hour, or 10-20 thousand a day.
>>
>> Thing is, 99 percent of those 10-20 thousand SOAP faults were for the
>> same few dozen bad data entries in System A. Sending an email for each
>> of those would have overwhelmed the human recipients. We recognized that
>> a separate ESB job that ran every 24 hours (and effectively called the
>> same intermediary logic) would capture all the problems, and it could
>> send out a *single* email that provided a summary of the bad data in
>> system A (and why it was bad).
>>
>> Point being, email notification on errors (as with logging errors to
>> file etc) are almost always going to a human being [2]. As such, the
>> urgency of an error dictates whether a notification should be sent at
>> all, how often an email should be sent, who gets it (human or system),
>> the nature of the email content (summary or single event), etc etc.
>>
>> To wit, for a large percentage of apps I think an "email per exception"
>> strategy will lead to drowning in emails. And you can Splunk or
>> grep|uniq|cut|cat|paste all that to your hearts's content...essentially
>> wasting your time to do what the reporting systems could have done in
>> the first place.

>
> Well - I am not convinced that the exception is the right choice
> when the data quality is as it is resulting in 10-20 thousand
> exceptions per day.


It is however the right choice for SOAP. Altering the body to introduce
error result codes introduces extra coupling between systems; SOAP
faults (which translate into Java runtime exceptions) are the standard
way of handling data validation errors, among other things.

That one system has poor data doesn't change this.

> But that type of scenario is seen frequently.


You betcha.

> But given the question, then I am not expecting the original
> poster to be working on that type of application.
>
> Arne


I'm not convinced that he is or isn't, Arne. The OP seemed to be
ostensibly OK with handling high volumes of emails...although that may
be seriously optimistic on his part.

AHS
--
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
catch doesn't catch a thrown exception Marteno Rodia Java 5 08-05-2009 03:30 AM
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
catch(...) doesn't catch everything Adam C++ 9 02-02-2006 05:02 PM
why catch (...) can not catch such exception John Black C++ 8 08-20-2004 02:34 PM



Advertisments