Java – deploy / redeploy applications to Tomcat’s pitpals without restarting

I have read that Tomcat 5.5 can deploy war to Tomcat server without restart That sounds great, but I think I'm too skeptical about this feature and its reliability My previous experience (using WebSphere) is the best practice of restarting the server to avoid memory problems So I want to get feedback on what pitfalls Tomcat may have

(in order to clarify my experience, I have developed Java Web applications for 5 years for a large company, which separates application developers from application server Engineers - we use WebSphere - so I don't have much experience in running / configuring any experience and apply the server myself)

Solution

Typically, there are multiple types of leaks that apply to redeployment scenarios For production systems, it is really best to restart if possible, because many different components and libraries are used in today's applications, which are difficult to find or even repair Esp. if you cannot access all source code

>Memory leak > thread and ThreadLocal leak > classloader leak > system resource leak > connection leak

Classloader disclosure is a redeployment vulnerability

They may be caused by everything Really, I mean everything:

>Timer: the timer has the thread created at runtime and the thread inherits the current context class loader, which means Tomcat's webappclassloader. > Threadlocals: threadlocals is bound to a thread Application server uses thread pool When ThreadLocal is bound to a thread and the thread is returned to the pool, if no one deletes () it correctly, ThreadLocal will remain there It often happens and is difficult to find (threadlocales have no name, except for spring namedthreadlocal, which is rarely used) If ThreadLocal contains classes loaded by webappclassloader, classloader leakage will occur. > Caching: e.g. ehcache CacheManager > reflection: JavaBeans introspection (e.g. holding class or method caches) > JDBC drivers: they should not be in anyway In the war file Static registry causes leakage > cache static libraries of classloaders, such as common logging LogFactory

As for tomcat, my experience is as follows:

>For a simple application with a "clean" library, it works well in Tomcat > Tomcat works very hard to clean up the classes loaded by the webapp classloader For example, when you undeploy webapp, the static fields of all classes are set to null This sometimes leads to nullpointerexceptions when running code at undeployment. For example, using the background work of the recorder > Tomcat has a listener that can clean up more things It is called org apache. catalina. core. Jrememoryleakpreventionlistener and recently submitted to Tomcat 6 x

I wrote a blog post about my experience with leaks when doing deployment stress testing – trying to "fix" all possible vulnerabilities in enterprise Java Web applications

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>