Reputation: 3079
I use openjpa and use store and commit.
Commit sometimes launches exception, but I can't get more precisions.
Sometimes, I guess It's integrity problem (storing twice the same date).
The error message and the stack are:
The transaction has been rolled back. See the nested exceptions for details on the errors that occurred.
<openjpa-2.4.1-r422266:1730418 fatal store error> org.apache.openjpa.persistence.RollbackException: The transaction has been rolled back. See the nested exceptions for details on the errors that occurred.
...
But where to find more detailed causes, or how to get nested exceptions ?
Thanks
Upvotes: 0
Views: 2489
Reputation: 6351
Had the same problem, JPA commit was nesting the exceptions from my JPA persist calls and burying them because I was only using e.getMessage()
public static List<String> getExceptionMessageChain(Throwable throwable) {
List<String> result = new ArrayList<String>();
while (throwable != null) {
result.add(throwable.getMessage());
throwable = throwable.getCause();
}
return result; //["THIRD EXCEPTION", "SECOND EXCEPTION", "FIRST EXCEPTION"]
}
catch(Exception e) {
// JPA Exceptions can be nested, need to get entire chain
getExceptionMessageChain(e).forEach(System.out::println);
}
Source: Get detail messages of chained exceptions Java
Upvotes: 1