StaleObjectStateException with two web servers and one database

Hi have next problem.

I have two different JBoss web servers, one for development and another for testing, both same datasource against one database (same database for two web servers), using Hibernate 4.2.18.

Sometimes one server gives me this error:

ERROR ExceptionTranslator:35 - concurrency error :
Object of class [entity.Encounter] with identifier [565]: optimistic locking failed;
nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [entity.Encounter#565]

Can be the two web servers the cause of the problem ,and if so how can I fix it?

Sure, but this can also happen on a single server. When you fetch an object in one transaction T1. Another transaction updates the same object. Then, in a transaction T2 you try to merge the previously fetched object, you might get a StaleObjectStateException. Another possible explanation for this is, when the other transaction deleted the object in the meantime.