In my application it's very likely that two or more entity beans with the same primary key (a string) get persisted at the same time. If that happens a "duplicate key" exception is raised and the the current transaction is being rolled back.
The problem is that it does not seem to be possible to recover from this error. Trying to catch the exception still leaves the transaction invalid. How can I make sure that I catch this kind of duplicate key exception without the current transaction being rolled back, when I call entityManager.persit(myEntityBean) ???
Try the EJB3 or Hibernate forums; JBoss Cache isn't throwing this exception, nor is it calling setRollbackOnly() on your tx.