Note that there are some explanatory texts on larger screens.

plurals
  1. POLogging all thrown Exceptions in a web application in Tomcat
    text
    copied!<p>Do you know any way to and log all exceptions that are ever thrown (whether catched and handled or not) in java?</p> <p>Here is my issue: There is an application, that I cannot change, and sometimes it has issues creating a lockfile (relevant code below). When it calls the tryLock() method , freezes for 30 seconds (despite the fact that tryLock is nonblocking), and returns with failure (CANT_CREATE_LOCK). As you see, all the catch tiers mask away the real problem, without even logging it.</p> <pre class="lang-java prettyprint-override"><code>final File lockFile = new File(fooHomeDir, ".foo-home.lock"); try { FileOutputStream stream = new FileOutputStream(lockFile); try { if (stream.getChannel().tryLock() == null) { return LockResult.HELD_BY_OTHERS; } this.fileOutputStream = stream; this.lockFile = lockFile; return LockResult.OK; } catch (OverlappingFileLockException overlappingFileLockException) { return LockResult.HELD_BY_OTHERS; } catch (IOException ie) { return LockResult.CANT_CREATE_LOCK; } } catch (FileNotFoundException fnfe) { return LockResult.CANT_CREATE_LOCK; } </code></pre> <p>What I wish: Able to see what was the details of the exceptions.</p> <p>Other info:</p> <ul> <li>The environment is Linux, Java 1.7, Tomcat 7.</li> <li>The fooHomeDir points to an NFS-backed mount point.</li> <li>The fooHomeDir's permissions did not change.</li> <li>The fooHomeDir's owner did not change.</li> <li>The fooHomeDir's filesystem is not full.</li> <li>There is no SELinux, or other thing that may interfere.</li> </ul> <p>Basically, it worked before, and stopped "suddenly" and "without cause". So right now I'm investigating.</p> <p>I'm commencing a remote debug of the application, but until then, suggestions are welcome :-)</p> <p>Thanks, joe</p> <p><strong>UPDATE</strong></p> <p>For the record, the root cause of the issue was that the rpc.statd daemon died. Hence, the native locking mechanism failed over NFS. The symptom was an IOException with the message: "No locks available".</p> <p>Kudos to Hans Maes</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload