2016-10-03 68 views
0

我是servlets和使用Tomcat 7.0.34版本的新手(我们被指示仅使用此版本)。我的问题是,Tomcat似乎在某个时间点重新启动,这发生在我一段时间不与servlet交互时。我看到以下内容:运行Servlet时的RuntimeException:Tomcat自己重新启动

enter image description here

此外,当我通过月食试图调试我看到在调试窗口中输入以下内容:

Daemon Thread [http-bio-80-exec-1] (Suspended (exception RuntimeException)) 
ThreadPoolExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: not available 
ThreadPoolExecutor$Worker.run() line: not available 
TaskThread(Thread).run() line: not available  

而这个控制台:

SEVERE: The web application [/csj] is still processing a request that has yet to finish. This is very likely to create a memory leak. You can control the time allowed for requests to finish by using the unloadDelay attribute of the standard Context implementation. 
Okt 03, 2016 1:39:39 AM org.apache.catalina.core.StandardContext reload 
INFO: Reloading Context with name [/csj] is completed 

我想知道为什么Tomcat是重新启动。如果我不停地点击按钮,那么就不会看到这个问题。

我试着在这里看:Tomcat showing this error "This is very likely to create a memory leak". How to resolve this issue?和在这里:The web application [ROOT] is still processing a request that has yet to finish. [Tomcat]但我很难理解。

看来这个问题已经解决了在更新版本的Tomcat根据这个:http://wiki.apache.org/tomcat/MemoryLeakProtection。不过,我想了解这个问题是什么。

编辑:使用Eclipse-MARS

回答

0

Tomcat的配置为“热部署”,即如果更改代码,tomcat会加入新的代码,而无需重新启动服务器。这可以在tomcat或eclipse中配置。你可以去那里禁用它,因为它实际上是一个头痛的问题,需要更多的时间,有时无法正常工作。
Tomcat使用单独的类加载器加载每个webapp。它监视你的文件的变化,如果发生变化,它会通过销毁类加载器来卸载你的web应用程序,并使用新的类加载器再次加载。发生这种情况时,您会看到您提到的各种日志。
对于蚀结构,见here
Tomcat的配置,参见here 另外,从Tomcat文档,读取this

+0

不幸的是,这并没有解决问题...我在控制台中看到以下内容:Okt 03,2016 8:17:13 PM org.apache.catalina.core.StandardContext reload INFO:Reloading Context with name [/BestDeal]已开始 2016年3月3日8:17:14 org.apache.catalina.core.StandardContext重新加载 信息:名称[/ BestDeal]的重新加载上下文已完成 – hrushi

+0

在\ tomcat \ conf \ server.xml中,在

+0

一个问题:在Servlet中使用getClass()是否会造成潜在的内存泄漏? – hrushi

0

在server.xml中,设置重新加载= “假”。

https://tomcat.apache.org/tomcat-5.5-doc/config/context.html

设置为true,如果你想卡塔利娜监视/ WEB-INF /班/和/ WEB-INF/lib目录更改类,并自动重新加载web应用程序,如果检测到变化。此功能在应用程序开发过程中非常有用,但它需要大量的运行时间开销,不建议用于已部署的生产应用程序。这就是为什么该属性的默认设置为false。但是,您可以使用Manager Web应用程序按需触发重新部署的应用程序。

+0

有一个问题:在servlet中使用getClass()会导致潜在的内存泄漏吗? – hrushi

相关问题