Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

problem with ServletContextListener

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i developped a servletContextListner witch calls 4 threads like it is shown below


one of my threads' code :

but that causes some problems like:

SEVERE: The web application [/CMS_GRM] created a ThreadLocal with key of type [org.glassfish.gmbal.generic.OperationTracer$1] (value [org.glassfish.gmbal.generic.OperationTracer$1@97c542a]) and a value of type [java.util.ArrayList] (value [[]]) 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.

SEVERE: [D:\apache-tomcat-7.0.52\work\Catalina\localhost\CMS_GRM\loader\META-INF] could not be completely deleted. The presence of the remaining files may cause problems

Threads do not execute in the order that i want

some time one of the threads is launched before the sleep period terminate (i don't know if it's the same instance of thread that is running or two instance:the newest one launched when i run the web application or there is an other insatnce witch is not stopped with an other execution of the web application

please help me if there should not be a problem when launching more than one thread in contextServletListner
and if it 's a problem is there an other solution ?
thanks in advance

 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two comments: In a production setting, avoid stopping and restarting web apps. It is very hard to avoid leaks, and can cause parts of the app to misbehave. Restarting the servlet container is the better approach.

Secondly, the contextDestroyed method is problematic, for two reasons. For starters, it silently swallows all exceptions, so you'll never know what's going on. Furthermore, if an exception happens while cleaning up the first thread, all further cleanup is skipped because it's all part of the same try block. You might want to think carefully about dependencies, and make the cleanup effort more granular.
 
rawia karoui
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your response
so how can i restart the servlet container and how to avoid starting and stopping the web app ?
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the way to avoid stopping and restarting web apps is to stop and restart the server :-) That's what the shutdown script in TOMCAT_HOME/bin does.
 
rawia karoui
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what about restarting the servlet container how can i do it?
 
Saloon Keeper
Posts: 24553
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rawia karoui wrote:what about restarting the servlet container how can i do it?



Tomcat is the servlet container. Restart tomcat, using the bin/shutdown and startup scripts or the bin/catalina script (bin/catalina.sh stop, bin/catalina.sh start).
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic