Glassfish在启动ubuntu 12.04时失败

时间:2014-05-28 14:34:40

标签: ubuntu amazon-ec2 ubuntu-12.04 glassfish-3

升级到最新版本的ubuntu 12.04之后。我的glassfish启动脚本在启动时失败。

以下是我的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|#]

但是,当我从控制台运行命令 sudo service glassfish start 时,服务就会正常运行。

这是我的初始脚本:

### 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

我会感谢任何帮助

1 个答案:

答案 0 :(得分:2)

最后,我使用 sudo update-rc.d -f glassfish remove 删除启动服务,并将脚本的执行添加到/etc/rc.local文件中。

#!/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