0

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

Andrew
  • 6,231
  • 2
  • 29
  • 37
  • Javadoc, perhaps? https://openjpa.apache.org/builds/1.0.1/apache-openjpa-1.0.1/docs/javadoc/org/apache/openjpa/persistence/RollbackException.html#getNestedThrowables() – Marko Topolnik Oct 05 '16 at 11:31
  • Where is the exception caught and sent to the logger? I think you might have only given it the message, not the exception itself, so it's not showing the stack and nested exceptions. – coladict Oct 05 '16 at 12:23
  • I agree with the previous comment. There should be more to the exception stack and there should be 'caused by' info. Look in your system output or logs for more details, enable OpenJPA trace, or do a 'printStackTrace()' when you catch the exception. – Heath Thomann Oct 05 '16 at 17:29
  • @coladict stacktrace is FailedObject: org.gramaco.Regle@1cb4f5f at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:595) and calls : ... not more usefull – guillaume girod-vitouchkina Oct 05 '16 at 20:25

1 Answers1

1

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

Andrew
  • 6,231
  • 2
  • 29
  • 37