In case of a service development wherein the service could be called by other services in the workflow, is it okay to handle java.lang.Error and runtime exceptions inorder to handle the flow gracefully (though Sun does not recommend so, I have been reading few latest articles in web that recommend otherwise). Thus I would like to know your views.
Thanks in advance for your valuable input and time.
I'd be inclined to catch as much as I could and throw application specific exceptions, but there are some errors that probably mean the JVM is so messed up that your attempt to throw something new won't work either.
What kind of environment are you running in? It's probably good to have some kind of service redundancy through load balancing and maybe even self healing restarts. In EJB land a service is just a thread within the container. If one dies, the container will likely start another.
In Forte 4GL (not Java) we had services that could automatically restart when they crashed and clients that could automatically retry. Crash, restart and retry could go on forever if the client is passing bad data that causes the crash, so even that has to have limits, eg only "n" retries.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi