After much investigation, we found that there is a connection timeout for the database user used to connect to the database and this may be the reason why all our database connections dies after periods of inactivity. We got rid of the timeout and haven't seen the problem since. However, as this problem only happens sporadically, only time will tell if this is the cause. I'll keep you guys posted.
Apparently Jboss doesn't refresh or monitor its db connections in the pool. I think this should be fixed in the future release.