New FileOutputStream () tomcat prompt likely to create a memory leak

I created the Excel file in a thread using
OutputStream stream = new FileOutputStream (path+fileName);
Tomcat issued a warning after the object was created

June 11, 2018 3:22:33 afternoon org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
warning: The web application [ACI] registered the JDBC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
June 11, 2018 3:22:33 afternoon org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
warning: The web application [ACI] appears to have started a thread named [startAutoChargeBackEmailJob_Worker-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
org.apache.commons.logging.LogFactory.getContextClassLoaderInternal (LogFactory.java:859)
org.apache.commons.logging.LogFactory.getFactory (LogFactory.java:423)
org.apache.commons.logging.LogFactory.getLog (LogFactory.java:685)
org.quartz.simpl.SimpleThreadPool.getLog (SimpleThreadPool.java:126)
org.quartz.simpl.SimpleThreadPool$WorkerThread.run (SimpleThreadPool.java:547)

what is the cause of this? has anyone encountered the same situation

Mar.18,2021

Basically, you can ignore this warning, which has nothing to do with your FileOutputStream, because the JDBC driver does not have unregister, but this only happens when tomcat is turned off, so it can be ignored. If you have to solve it, do this:

Register a listener: in web.xml

<web-app version="2.5"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <listener>
      <listener-class>
          example.ServletContextExample
      </listener-class>
  </listener>
</web-app>

then in this listener implementation, drive jdbc to unregister:

Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
    Driver driver = drivers.nextElement();
    try {
        DriverManager.deregisterDriver(driver);
    } catch (SQLException e) {
    }
}

Menu