0

I am new to servlets and using Tomcat version 7.0.34 (we were instructed to use this version only). My problem is that the Tomcat seems to restart at some point of time, this occurs when I don't interact with the servlet for some time. I see the following:

enter image description here.

Further when I tried debugging through eclipse I see the following entries in the debug window:

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    

And this in console:

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

I want to know the reason why Tomcat is restarting. If I keep clicking the buttons with no delays, then this problem is not seen.

I tried looking here: Tomcat showing this error "This is very likely to create a memory leak". How to resolve this issue? and here: The web application [ROOT] is still processing a request that has yet to finish. [Tomcat] but I am at loss to understand.

It seems this problem is solved in newer version of Tomcat as per this:http://wiki.apache.org/tomcat/MemoryLeakProtection . Nevertheless I would like to understand what is this problem about.

Edit: Using eclipse-mars

Community
  • 1
  • 1
hrushi
  • 294
  • 1
  • 10

2 Answers2

0

Your tomcat is configured for "hot deploy" i.e. if you change code, tomcat will incorporate new code without a server restart. This can be configured on tomcat, or in eclipse. You can go there and disable this as it is actually a headache and consumes more time, and sometimes doesn't work correctly.
Tomcat loads each webapp using a separate classloader. It monitors your files for changes, and if a change happens, it unloads your webapp by destroying the classloader, and loads again using a new class loader. When this is happening, you will see all kinds of logs as you mentioned.
For eclipse configuration, see here
For tomcat configuration, see here Also, from Tomcat docs, read this

Community
  • 1
  • 1
Apurva Singh
  • 4,534
  • 4
  • 33
  • 42
  • unfortunately this didn't solve the issue... I see the following in console:Okt 03, 2016 8:17:13 PM org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/BestDeal] has started Okt 03, 2016 8:17:14 PM org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/BestDeal] is completed – hrushi Oct 04 '16 at 01:22
  • In \tomcat\conf\server.xml, under – Apurva Singh Oct 06 '16 at 14:41
  • One question: does using getClass() inside the servlets be a reason for potential memory leaks? – hrushi Oct 10 '16 at 07:44
0

In server.xml, set reloadable="false".

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

Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.

HARDI
  • 394
  • 5
  • 12
  • One question: does using getClass() inside the servlets be a reason for potential memory leaks? – hrushi Oct 10 '16 at 07:45