Search code examples
ubuntuamazon-ec2ubuntu-12.04glassfish-3

Glassfish fails at start up ubuntu 12.04


after upgrade to the latest version of ubuntu 12.04. My glassfish startup script fails at boot.

Here are the relevant parts of my boot.log:

Error starting domain XXXYYY.
The server exited prematurely with exit code 0.
Before it died, it produced the following output:
.....
adName=Grizzly-kernel-thread(1);|doSelect IOException
java.net.BindException: No free port within range: 8181=com.sun.enterprise.v3.services.impl.monitor.MonitorableSSLSelectorHandler@19e2595
......
[#|2014-05-28T09:08:28.639-0500|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=1;_ThreadName=main;|Shutting down v3 due to startup exception : No free port within range: 80=com.sun.enterprise.v3.services.impl.monitor.MonitorableSelectorHandler@197e2a6|#]

But, when I run the command from console sudo service glassfish start the service starts fine.

This is my init script:

### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

#!/bin/sh
#
# glassfish init script for Linux
# Simplest possible case -- no password file, one default domain
# it would be simple to add such options

GLASSFISH_HOME=${GLASSFISH_HOME:-"/home/glassfish"}

case "$1" in
start)
    $GLASSFISH_HOME/bin/asadmin start-domain XXXYYY >/dev/null
    ;;
stop)
    $GLASSFISH_HOME/bin/asadmin stop-domain XXXYYY >/dev/null
    ;;
restart)
    $GLASSFISH_HOME/bin/asadmin restart-domain XXXYYY >/dev/null
    ;;
\*)
    echo "usage: $0 (start|stop|restart|help)"
esac

I will thank any help


Solution

  • Finally I remove the startup service with sudo update-rc.d -f glassfish remove and added the execution of the script to the /etc/rc.local file.

    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    exit 0
    
    /etc/init.d/glassfish start