문제

In particular, I want to know if a (the?) servlet context associated with a particular web application can be initialized, destroyed, and initialized again within the same JVM.

도움이 되었습니까?

해결책

The JVM is simply the virtual machine that runs all java code, JBoss being an example of running java code (JBoss is not a JVM).

Next, the JBoss Application Server build upon that virtual machine, and internally creates the "container environment" that is required to offer the services of the JEE specifications (of which Servlets is a part).

A JEE application can consist of several different deployable artifacts including Enterprise Java Bean (Stateless and Stateful Session Beans, Message Driven Beans), Web Applications (WARs), and Enterprise Applications (EARs, which are combinations of other artifacts like EJBs and WARs).

A Servlet is a component of a Web Application. A Servlet is not a deployable artifact on its own.

Web Applications can be deployed, started, stopped, undeployed, and redeployed in to a running JEE container (such as JBoss). It is part of the containers responsibility to enable this capability as well as ensuring that it can be done reasonably safely. It is also the containers responsibility to help to isolate the different deployable artifacts from each other (typically through class loader shenanigans).

So, in this sense, a WAR which contains a Servlet, can be deployed, executed, stopped, undeployed, and then deployed again in to a running container safely. The individual Servlet can not, just the WAR as a whole.

However, because of the reality of the JVM, the truth is that components can only be so isolated from each other, there are things that can cause components to leave traces behind even after the component has been removed from the running server, and other issues.

As a general rule, it MOSTLY works, works well and reliably, but different containers do things differently, and badly behaved components can wreak havoc on a live JVM (by design or not).

The simpler the application the more likely it is to work quite well. Start playing games with threads, off heap memory, jars not bundled with the applications, etc., those can lead to trouble.

다른 팁

Based on the question's comment thread, and other supporting research, it would appear that JBoss does not launch a separate JVM for different web applications, and the implication is there would be no other way for JBoss to redeploy a web application except within the same JVM.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top