GlassFish 社区实现了开源 Java EE 5 应用服务器。GlassFish 是一款强健的商业兼容应用服务器,达到产品级质量,可免费用于开发、部署和重新分发。
GlassFish 是用于构建 Java EE 5 应用服务器的开源开发项目的名称。它基于 Sun Microsystems 提供的 Sun Java System Application Server PE 9 的源代码以及 Oracle 贡献的 TopLink 持久性代码。该项目提供了开发高质量应用服务器的结构化过程,以前所未有的速度提供新的功能。这是对希望能够获得源代码并为开发 Sun 的下一代应用服务器(基于 GlassFish)作出贡献的 Java 开发者作出的回应。该项目旨在促进 Sun 和 Oracle 工程师与社区之间的交流,它将使得所有开发者都能够参与到应用服务器的开发过程中来。
1. 首先在 创建文件/etc/init.d/glassfish3, 文件内容如下. 注意修改下列内容的红色部分(不好意思,全部用英文写的)
#! /bin/sh # This shell script takes care of starting and stopping # the glassfish DAS and glassfish instance. # # chkconfig: - 64 36 # description: glassfish management # processname: glassfish #if you face any problems add the path to your Java #this way (see Jeffrey's comments below) export AS_JAVA=<SPAN style="COLOR: #ff0000">/usr/java/jdk1.6.0_17</SPAN> #export CLASSPATH=.;$AS_JAVA/lib/dt.jar;$AS_JAVA/lib/tools.jar GLASSFISHPATH=<SPAN style="COLOR: #ff0000">/opt/glassfish3/bin</SPAN> export PASSWD=<SPAN style="COLOR: #ff0000">/opt/glassfish3/bin/.passwd</SPAN> case "$1" in start) echo "starting glassfish from $GLASSFISHPATH" su - root $GLASSFISHPATH/asadmin start-domain #start your instance at start time, if you do not have instance, comment these two lines <SPAN style="COLOR: #ff0000">echo "starting instance st_server" $GLASSFISHPATH/asadmin --user admin --passwordfile $PASSWD start-instance st_server </SPAN> #we need to use this later when we enable https #sudo -u glassfish $GLASSFISHPATH/asadmin --secure start-domain domain1 ;; status) $0 start ;; restart) $0 stop $0 start ;; stop) <SPAN style="COLOR: #ff0000">echo "stopping instance st_server" $GLASSFISHPATH/asadmin --user admin --passwordfile $PASSWD stop-instance st_server </SPAN> echo "stopping glassfish from $GLASSFISHPATH" su - root $GLASSFISHPATH/asadmin stop-domain #we need to use this later when we enable https #sudo -u root $GLASSFISHPATH/asadmin --secure stop-domain domain1 ;; *) echo $"usage: $0 {start|stop|restart|status}" exit 3 ;; esac设置成可执行文件,
$ sudo chmod +x /etc/init.d/glassfish3
其中的password文件如下
AS_ADMIN_PASSWORD=administration-password
请将 administration-password修改成你自己的密码
2. 查看刚刚添加的服务
chkconfig --list glassfish3你应该看到