Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper way of "shutdown" a spring context in J2SE

Tags:

java

spring

I'm currently experiencing problems with a JPATransactionManager in a J2SE application.

The latest request was not properly saved in the database (surely a problem of cache).

This seems to be normal because the exit of the program does not seem to "cleanly" exit all Bean of the spring application context.

Do you know if there's a method of a clean shutdown a Spring context before exiting ?

Thank you in advance.

like image 940
X-Blaster Avatar asked Feb 19 '10 11:02

X-Blaster


1 Answers

Checkout Spring Reference manual on this topic.

Basically you need to call registerShutdownHook() on the application context.

like image 108
DJ. Avatar answered Oct 20 '22 17:10

DJ.