0

(A similar question here is related to Tomcat resources, not spring boot managed beans)

Two Hikari DataSource pools are being creating like this:

@Primary
    @Bean(value="appDataSource",destroyMethod="close")
    @ConfigurationProperties("app.db.datasource")
    @Override
    public DataSource dataSource() {
        return DataSourceBuilder.create().build(); 
    }


@Bean(value="pacsDataSource",destroyMethod="close")
    @Override
    public DataSource dataSource() {
        return new HikariDataSource(hikariConfig());
    }

But when the application is shut down I see the below errors in the logs and the java process fails to exit. From what I can tell spring should be calling close() on those datasources, which should terminate the pool threads.

 2023-04-24T11:02:24.758 [https-jsse-nio-8080-exec-2] WARN  org.apache.catalina.loader.WebappClassLoaderBase - The web application [ROOT] appears to have started a thread named [HikariPool-1 housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
     java.base@15.0.1/jdk.internal.misc.Unsafe.park(Native Method)
     java.base@15.0.1/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
     java.base@15.0.1/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)
     java.base@15.0.1/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
     java.base@15.0.1/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
     java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)
     java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
     java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
     java.base@15.0.1/java.lang.Thread.run(Thread.java:832)

2023-04-24T11:02:24.759 [https-jsse-nio-8080-exec-2] WARN  org.apache.catalina.loader.WebappClassLoaderBase - The web application [ROOT] appears to have started a thread named [HikariPool-2 housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.base@15.0.1/jdk.internal.misc.Unsafe.park(Native Method)
 java.base@15.0.1/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
 java.base@15.0.1/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:1661)
 java.base@15.0.1/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
 java.base@15.0.1/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
 java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1056)
 java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1116)
 java.base@15.0.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
 java.base@15.0.1/java.lang.Thread.run(Thread.java:832)

Edit: Oddly enough I have one VM where this error does not prevent the java process from exiting. So I'm working on trying to figure out the difference. The .jar is exactly the same, but there are other environmental differences. Either way it seems like the process should exit when spring is boot shutdown.

The Shoe Shiner
  • 697
  • 4
  • 20
  • It's not a ready solution, however this is the official explanation about this kind of messages: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=103099526 – Pino Apr 24 '23 at 16:00
  • @Pino Yea unfortunately that doesn't really explain why spring isn't shutting down the Hikari datasource, which is started up by spring itself. – The Shoe Shiner Apr 26 '23 at 11:19
  • The error message says that your Spring-boot based web app is named "ROOT". Is it true? I guess no. This is something to investigate. – Pino Apr 26 '23 at 13:04
  • @Pino Yes I am not sure why it says that. I assumed it was something that spring generated automatically, but I'm not certain. – The Shoe Shiner Apr 26 '23 at 20:41

1 Answers1

0

I had @Type annotation which I removed and got the error then again I put it so error resolved.

  @Type(type = "json")
    @Column(columnDefinition = "json", name = "payload")
    private Map<String, String> payload;
  • Answer not clear: Can you add a brief explanation please? – ryanwebjackson Jul 16 '23 at 13:47
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 16 '23 at 19:53