I use Java and Spring Boot. I implemented the correct termination of the application when receiving the SIGTERM command.
Set the settings for SpringBoot:
server:
shutdown: graceful
spring.task.execution:
pool:
allow-core-thread-timeout: true
keep-alive: 3m
shutdown:
await-termination: true
await-termination-period: 3m
And I also tried it with ThreadPoolTaskExecutor
:
ThreadPoolTaskExecutor defaultExecutor = new ThreadPoolTaskExecutor();
defaultExecutor.setKeepAliveSeconds(180);
defaultExecutor.setWaitForTasksToCompleteOnShutdown(true);
defaultExecutor.setAwaitTerminationSeconds(180);
But I ran into a problem. In an asynchronous thread, the SOAP method is called and it crashes with an error:
ERROR [iso20022.app.FCR,3b58933b54e5e47c,1eb7da1d0650e9d9] 2808 --- [ h2h-async1] r.a.h.c.RepeaterInvocationHandler : error on calling jdk.proxy6.$Proxy236.wsAccountBaseInfoGet
java.lang.ExceptionInInitializerError: null
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.getTransport(HttpTransportPipe.java:154) ~[jaxws-rt-2.3.1.jar:2.3.1]
…
Caused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [META-INF/services/javax.xml.bind.JAXBContext]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1432) ~[tomcat-embed-core-9.0.76.jar:9.0.76]
at org.apache.catalina.loader.WebappClassLoaderBase.getResourceAsStream(WebappClassLoaderBase.java:1140) ~[tomcat-embed-core-9.0.76.jar:9.0.76]
at javax.xml.bind.ContextFinder.firstByServiceLoaderDeprecated(ContextFinder.java:611) ~[jaxb-api-2.4.0-b180830.0359.jar:2.3.0]
Please, help. What do I need to do?