users@glassfish.java.net

Re: Have to restart server to enable virtual hosts

From: <glassfish_at_javadesktop.org>
Date: Wed, 16 Jun 2010 06:43:01 PDT

We encountered the same issue and I managed to discover a way to reproduce this using glassfish v3.0.1.

The problem: when more than 1 project is deployed in a virtual server and these projects have no context root (ie use / as context root), then a redeploy of 1 of these projects will cause all the other projects to display the default index page in the docroot.

Reproducing: create three virtual servers: vs1, vs2 and vs3. Make three web applications and deploy each of them in their own virtual server. Two of the three applications should be deployed using / as the context root. The third application must have a context root (ie /myapp).
When you now go to the applications they will all work. Now redeploy one of the applications without a context root. You will now notice that the other application without a context root will not work anymore. The application with the context root still works, as does the redeployed application.

For the lazy ones, you can unzip the file attached to this post. After that execute the following commands:

asadmin create-virtual-server --networklisteners http-listener-1 --hosts vsnoroot1.localhost vsnoroot1
asadmin create-virtual-server --networklisteners http-listener-1 --hosts vsnoroot2.localhost vsnoroot2
asadmin create-virtual-server --networklisteners http-listener-1 --hosts vscontext.localhost vscontext

asadmin deploy --virtualservers vsnoroot1 --force VirtualServerDeployRoot1.war
asadmin deploy --virtualservers vsnoroot2 --force VirtualServerDeployRoot2.war
asadmin deploy --virtualservers vscontext --force VirtualServerDeployContextRoot.war

Configure your /etc/hosts file so your browser will detect the *.localhost addresses. Then check all applications: http://vsnoroot1.localhost, http://vsnoroot2.localhost and http://vscontext.localhost/VirtualServerDeployContextRoot. All three should work. Now redeploy the first application:

asadmin deploy --virtualservers vsnoroot1 --force VirtualServerDeployRoot1.war

Application 2 (http://vsnoroot2.localhost) should now give you the default index.html page from the docroot.
[Message sent by forum member 'tiainen']

http://forums.java.net/jive/thread.jspa?messageID=474496