You get the WrongStateException if you try to call an oporation on a transaction that is not valid in the current state. For example, if you try to commit a transaction before you have begun it. See here: