I know this is unrelated to your work, but this log statement will only print the message of the exception and not the stack trace. You can you use sw instead of ex?