Java tomcat重新加载时Spring MVC+Spring Hadoop内存泄漏

Java tomcat重新加载时Spring MVC+Spring Hadoop内存泄漏,java,spring,spring-mvc,hadoop,spring-data,Java,Spring,Spring Mvc,Hadoop,Spring Data,我希望使用SpringMVC编写一个与hadoop交互的servlet。由于hadoop核心依赖jetty和tomcat,我需要将它们排除在外,如中所述 我试图使用spring创建一个org.apache.hadoop.fs.FileSystem对象,如下所示 <hdp:configuration file-system-uri="hdfs://localhost:9000"/> <hdp:file-system/> @Controller public cla

我希望使用SpringMVC编写一个与hadoop交互的servlet。由于hadoop核心依赖jetty和tomcat,我需要将它们排除在外,如中所述

我试图使用spring创建一个org.apache.hadoop.fs.FileSystem对象,如下所示

<hdp:configuration file-system-uri="hdfs://localhost:9000"/>    
<hdp:file-system/>
@Controller
public class SomeController {

    @Autowired FileSystem hdfs;
文件系统操作按预期工作,但tomcat报告servlet重新加载时内存泄漏:

Feb 11, 2015 4:14:28 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/hadoopsync] created a ThreadLocal with key of type [org.apache.hadoop.hdfs.DFSUtil$1] (value [org.apache.hadoop.hdfs.DFSUtil$1@38504b85]) and a value of type [java.util.Random] (value [java.util.Random@1f8e25a5]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Feb 11, 2015 4:14:28 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/hadoopsync] created a ThreadLocal with key of type [org.apache.hadoop.io.Text$1] (value [org.apache.hadoop.io.Text$1@2d4983d2]) and a value of type [sun.nio.cs.UTF_8.Encoder] (value [sun.nio.cs.UTF_8$Encoder@356d6738]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
重新启动几次后,tomcat出现内存不足异常。我尝试过在@PreDestroy方法中显式调用bothorg.apache.hadoop.fs.FileSystem.close和org.apache.hadoop.fs.FileSystem.closeAll,并像下面这样向spring config传递额外的参数 手动获取并关闭这样的文件系统对象

@Autowired Configuration config;
@PostConstruct
public void init() {
    //immediately getting, then closing an object still results in a leak
    FileSystem fs = FileSystem.get(config);
    fs.close(); //also tested closeAll here
}

我不确定是否有另一种策略可以让hadoop/spring hadoop在servlet中管理生命周期方法,或者我是否试图以不合理的方式将这些库结合使用。我在servlet中找不到任何spring hadoop的示例,而且也没有介绍它。还有其他方法让servlet与hadoop对话吗?

使用tomcat管理器进行重新部署总是会导致代码不同部分出现各种内存泄漏,我们浪费了大量时间试图解决这些问题,但完全没有成功。我们只是放弃了使用tomcat管理器,只完成了重新启动。当然,投资于JRebel。