It's used in a DAO like so:
Due to a lack of coffee, I forgot to upload the new DateUtils.class file to the server. When this DAO hit that line, it did not throw an error. In fact, it restarted the application! All I saw in the log was "context restarting". After lots of debugging statements and a couple cups of coffee, I figured out my dumb mistake and now all is well, but this would have been a lot easier to diagnose if the log had contained an error.
Why was there no "method not found" message or something similar? Can I change my code to make sure I get an exception when something like this happens?
It seems odd, I know. Just as odd as the fact that all the date fields in our database are actually strings. The programmers never use the DATE or DATETIME data types.
Jaikiran Pai wrote:However, do note that "no method found" is an Error http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodError.html and not an Exception and as such won't be caught in a catch (Exception) block but will be caught in a catch(Throwable) block. Perhaps, there's some piece of code which is catching it and restarting the context?
Good point. I searched for "throwable" and found 359 matches. I'm looking through them now. There is a SessionManager with an overridden finalize method that looks suspicious. This DAO is being run from a context listener, and I don't know how sessions work when using a listener.
I'm going to do a little experimenting by adding a catch(Throwable) block and then commenting out that method.