users@glassfish.java.net

Using /etc/HOSTNAME as v-server name may cause strange breakage

From: <glassfish_at_javadesktop.org>
Date: Sun, 08 Apr 2007 08:51:12 PDT

This is one of those obscure, "moon must be aligned with jupiter and the tides just right" kind of bugs that rarely strikes, and causes bizarre, inexplicable effects when it does. As-is it's very hard to hit, but I have no idea wether it might be struck upon in different circumstances too. Basically, if the servers hostname, as seen in /etc/HOSTNAME, is registerd in DNS, comes first in /etc/hosts for the servers IP address, and is used as the name for a virtual server in GF, then either deploying something to the "/" context root on that vserver or setting a default web module causes strange breakage of the deployed application and the web admin console, and possibly of other things too. No exceptions accompany any of this breakage.

I've only tested this on OpenSUSE 10.2, and have no idea if it'll show up on other OS'es or even other version of SUSE. I'm using java 1.6.0_01, and have tested on SJSAS 9.0_01 (build b02-p01) and GFv2 (build b41-beta2).

A. OS Settings:
1. /etc/HOSTNAME must be registerd in DNS. (Causes an exception to be dumped on console but not logged to server.log if not, but nothing actually breaks.)
2. /etc/HOSTNAME must appear as first entry in /etc/hosts for that servers IP (For a server www.foo.com with IP 1.2.3.4, the first line with 1.2.3.4 in /etc/hosts must be "1.2.3.4 www.foo.com".)
Maybe something else too, but I haven't found anything else to tweak that stops this from happening. Oh, and just writing to /etc/HOSTNAME didn't work on SUSE, I had to configure it in Yast.

B. Then:
1. Create a virtual host with the name found in /etc/HOSTNAME.
./asadmin create-virtual-server --hosts $HOSTS --httplisteners "http-listener-1,http-listener-2" `cat /etc/HOSTNAME`

2. And deploy something to it:
./asadmin deploy --virtualservers `cat /etc/HOSTNAME` --contextroot / --name myapplication $SOME_WAR_FILE

Presto: http://localhost:4848 no longer forwards to /asadmin (SJSAS 9.0) or serves the web console (GFv2). I get a 404 on SJSAS 9.0, and a 503 or the deployed application on GFv2b41. http://localhost:4848/asadmin still works on SJSAS 9.0, but undeploying the application again renders that unusable too. Still not sure under what circumstances the application I try to deploy becomes available where it's supposed to.

WORKAROUND:
Don't use /etc/HOSTNAME as virtual server name


I'd file a bugreport, but I've no idea which subcomponent it's related to. And I'm not expecting anyone to jump on this, it's just something I discoverd and will be working around, but felt obliged to share anyway.
[Message sent by forum member 'thormick' (thormick)]

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