0

I've the following case:

enter image description here

When the asynchronous processing of the thread is finished, an exception is thrown at line 15 with the following message: Transactions is not active.

Notice that I set the transaction timeout, because the error occurs only after several minutes of execution of the method "doAnything()" When execution take one or two minutes, the error does not occur. However, setting the timeout did not work.

Any idea?

Thanks.

Rafael Orágio
  • 1,718
  • 5
  • 19
  • 26

1 Answers1

0

This bean is illegal -- you cannot start a new thread. Doing so goes behind the back of the container and you lose your transaction management, security management and more.

See this answer for details on how transaction propagation works under the covers

See this answer for how you can use @Asynchronous instead of starting your own threads

Note, even with @Asynchronous you cannot have a transaction that spans multiple threads. There are no TransactionManagers out there that can support it and therefore the specs do not allow it.

Community
  • 1
  • 1
David Blevins
  • 19,178
  • 3
  • 53
  • 68