installing Glassfish on CentOS

Assuming Java is already installed and JAVA_HOME is set

cd /opt
wget http://download.java.net/glassfish/3.1/release/glassfish-3.1.zip
unzip -q glassfish-3.1.zip
groupadd glassfish
useradd -s /bin/bash -g glassfish glassfish
chown -R glassfish:glassfish /opt/glassfish3/

/etc/init.d/glassfish:

#! /bin/bash
#
# glassfish Start/Stop the glassfish application server
#
# chkconfig: 345 80 20
# description: GlassFish is an open source application server project \
#              led by Sun Microsystems for the Java EE platform
#              
# processname: glassfish.jar
# config: 
# pidfile: /var/run/glassfish.pid

# Source function library.
. /etc/init.d/functions
#. /etc/sysconfig/glassfish
 
GLASSFISH_HOME=/opt/glassfish3
GLASSFISH_USER=glassfish

# See how we were called.
  
prog="glassfish"

start() {
        echo  $"Starting $prog: "
        if [ -e /var/lock/subsys/glassfish ]; then
            if [ -e /var/run/glassfish.pid ] && [ -e /proc/`cat /var/run/glassfish.pid` ]; then
                echo -n $"cannot start glassfish: glassfish is already running.";
                failure $"cannot start glassfish: glassfish already running.";
                echo
                return 1
            fi
        fi
        su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
        RETVAL=$?
        PID=$(pgrep -f glassfish.jar)
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/glassfish && echo $PID > /var/run/glassfish.pid;
        return $RETVAL
}

stop() {
        echo  $"Stopping $prog: "
        if [ ! -e /var/lock/subsys/glassfish ]; then
            echo -n $"cannot stop glassfish: glassfish is not running."
            failure $"cannot stop glassfish: glassfish is not running."
            echo
            return 1;
        fi
        su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/glassfish && rm /var/run/glassfish.pid;
        return $RETVAL
}

rhstatus() {
        status glassfish
}

restart() {
        stop
        start
}



case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        rhstatus
        ;;
  condrestart)
        [ -f /var/lock/subsys/glassfish ] && restart || :
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart}"
        exit 1
esac

/etc/httpd/conf.d/glassfish.conf (or put in a vhost):

ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/