Friday, August 17, 2012

Glassfish 3.1.2

Have you installed Glassfish 3.1.2 on a Solaris variant? For one thing, it has SMF integration, that is, it creates (optionally) a service that can be controlled by svcadm. And then there are the functionalities that are available on all platforms. For example, clustering (both on the open source edition and oracle supported versions). So, basically, it is just a matter of downloading the file and then, as root (or sudo or pfexec depending how you are set up):
# sh glassfish-3.1.2-unix-ml.sh
Extracting the installer archive...
Extracting the installer runtime...
Extracting the installer resources...
Extracting the installer metadata...
Welcome to GlassFish installer
Using the user defined JAVA_HOME : /
Entering setup... SwixML 1.5 (#144)
This will bring up the usual GUI installer (assuming you are installing in the global zone, or you ssh -X to your zone). Make sure you select custom instead of express install. Now, this is pretty straightforward, and wouldn't merit a blog entry, but I wanted to bring up at least one thing that might stump you if you are installing in a solaris container / zone. The web admin (port 4848) expects localhost, as in http://localhost:4848, else it will error out. If we are in a zone, it is not too convenient. Sure, you could do an ssh -X zone_name and then run firefox from the zone:
# ssh -X server1
Oracle Corporation SunOS 5.11 11.0 May 2012
user@server1:~$ firefox -no-remote
This will launch firefox from the zone. Without the -no-remote, firefox will run in the global zone, and the login to the admin console will fail: Error Configuration Error Secure Admin must be enabled to access the DAS remotely. Again, you could do that... A better approach is to enable access through the host (zone) name instead of localhost. How?
cd /opt/glassfish3/bin
./asadmin --host server1 --port 4848 enable-secure-admin
Replace server1 by the hostname of the zone and you are almost there. For the change to take place, a restart of the app server is required. Easiest is reboot of the zone, but hold on! We have to make sure the service is enabled:
user@server1:~$ svcs domain1Service
STATE STIME FMRI disabled 13:35:17 svc:/application/GlassFish/domain1Service:default
user@server1:~$ su
root@server1:~# svcadm enable domain1Service
root@server1:~# svcs domain1Service
STATE STIME FMRI offline* 15:15:10 svc:/application/GlassFish/domain1Service:default
root@server1:~# svcs domain1Service
STATE STIME FMRI maintenance 15:15:19 svc:/application/GlassFish/domain1Service:default
The first time around it will be in maintenance, because glassfish is already running. We issue a reboot command in the zone and once it comes back up:
user@server1:~$ svcs domain1Service
STATE STIME FMRI online 15:18:11 svc:/application/GlassFish/domain1Service:default
That is it. We can now access http://server1:4848