Using Atomikos transaction manager one will frequently see following stacktrace:
11-08-25 08:49:21,927 [http-7380-Processor21] Error during afterCompletion
java.lang.IllegalStateException: Unexpected state: afterCompletion called with status 5
At http://fogbugz.atomikos.com/default.asp?community.6.802.3 it is explained that Atomikos calls afterCompletion() with state unknown for read-only transactions. It also says that this does not comply to J2EE spec.
To prevent the stacktraces in log and influences by the exception thrown we have to handle this situation.