OutOfMemoryError when hot-deploying SpringMVC app to Tomcat7 - possible relation to log4j2

前端 未结 3 604
萌比男神i
萌比男神i 2021-01-28 12:20

I am having trouble Hot Deploying a Spring-MVC 4.0 (not SpringBoot) Web Application. I am trying to go xml-less and just use JavaConfig. OutOfMemoryErrors result when

3条回答
  •  闹比i
    闹比i (楼主)
    2021-01-28 12:49

    I believe Luke is right that this issue may be caused by a bug in Log4j2.

    The bug is that if the element is not present in the web.xml, the Log4jServletContextListener class responsible for log4j resource management can only start, but not stop log4j.

    This means that no cleanup happens when the web application is stopped or restarted. JMX MBeans are not unregistered, but also any threads are not stopped, and as a result Log4j classes are not unloaded. The leaked memory grows every time the web app is restarted, because each web app has its own classloader (so the VM sees them as different classes).

    This bug is fixed in Git master now and the fix will be part of the log4j 2.5 release. Meanwhile, please use a element in your web.xml.

提交回复
热议问题