My action is read-only. It only calls some injected DAO's get / list methods.
After I annotated the action @UnitOfWork (to get rid of the previous problem) , it sometimes throws exception :
java.lang.IllegalStateException: Work already begun on this thread. Looks like you have called UnitOfWork.begin() twice without a balancing call to end() in between.
at com.google.inject.internal.util.$Preconditions.checkState(Preconditions.java:142) ~[guice-3.0.jar:na]
at com.google.inject.persist.jpa.JpaPersistService.begin(JpaPersistService.java:66) ~[guice-persist-3.0.jar:na]
at ninja.jpa.UnitOfWorkInterceptor.invoke(UnitOfWorkInterceptor.java:53) ~[ninja-core-3.1.1.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0-ea]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.8.0-ea]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0-ea]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0-ea]
at ninja.params.ControllerMethodInvoker.invoke(ControllerMethodInvoker.java:55) ~[ninja-core-3.1.1.jar:na]
It doesn't always throw this exception , just about 50/50 .
Generally I first load the page , it shows ok .
After refreshing 2 or 3 times ( or more) , the problem shows.
My action calls some DAO's get/list methods , which are not annotated anything.
The solution is simple , replace action's @UnitOfWork to @Transactional
But that's too overkill. (transaction is heavy)
I am sure the underlaying DB calls don't contain any @Transactional methods.
What may be wrong here ?