GlassFish 是一款强健的商业兼容应用服务器,达到产品级质量,可免费用于开发、部署和重新分发。开发者可以免费获得源代码,还可以对代码进行更改。
在遵守通用开发和发布许可 (Common Development and Distribution License, CDDL) 版本 1.0 的前提下,开发者可以免费获得源代码,还可以对代码进行更改(只要他们认为合适)。要申请 Java Compatibility,商业分发的开发者需要签署 Java Developer License (JDL),并在重新分发代码前验证代码已通过兼容性测试套件 (compatibility test suite, CTS) 的测试。任何人均可签署分发协议,对代码进行审阅以贡献更改、错误修复和功能。https://javaee.github.io/glassfish/LICENSE
glassfish下载地址:https://download.oracle.com/glassfish/5.0.1/release/index.html
下载后解压即完成安装,主要目录说明:
bin目录:为asadmin命令所在目录。
glassfish为主目录:
glassfish\bin目录为命令目录。
glassfish\docs 目录为快速使用手册。
glassfish\domains为默认域目录。
1. 通过asadmin create-domain命令建域,输入默认用户名与密码。
D:\glassfish5\bin> asadmin create-domain aaa
Enter admin user name [Enter to accept default "admin" / no password]>admin
Enter the admin password [Enter to accept default of no password]>
Enter the admin password again>
Default port 4848 for Admin is in use. Using 51364
Default port 8080 for HTTP Instance is in use. Using 51365
Default port 7676 for JMS is in use. Using 51366
Default port 3700 for IIOP is in use. Using 51367
Default port 8181 for HTTP_SSL is in use. Using 51368
Using default port 3820 for IIOP_SSL.
Using default port 3920 for IIOP_MUTUALAUTH.
Default port 8686 for JMX_ADMIN is in use. Using 51369
Using default port 6666 for OSGI_SHELL.
Using default port 9009 for JAVA_DEBUGGER.
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=realw,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=realw-instance,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
Domain aaa created.
Domain aaa admin port is 51364.
Domain aaa admin user is "admin".
Command create-domain executed successfully.
2. 通过asadmin start-domain命令启动域
D:\glassfish5\bin> asadmin start-domain aaa
Waiting for aaa to start ...
Successfully started the domain : aaa
domain Location: D:\glassfish5\glassfish\domains\aaa
Log File: D:\glassfish5\glassfish\domains\aaa\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.
3. 通过asadmin stop-domain命令停止域
D:\glassfish5\bin> asadmin stop-domain aaa
Waiting for the domain to stop .
Command stop-domain executed successfully.
前提:domain已经启动。
访问控制台:http://IP地址:4848(默认控制台端口为4848),输入建域时的用户名密码登录。
登录控制台后左边树菜单如下,常用配置部署应用如下图:
配置数据源如下, _TimerPool是为EJB timer使用,是glassfish的典型特征。
JVM等主要配置项如下:
-XX:MaxPermSize=192m
-client
-Djava.awt.headless=true
-Djdk.corba.allowOutputStreamSubclass=true
-Djdk.tls.rejectClientInitiatedRenegotiation=true
-Djavax.xml.accessExternalSchema=all
-Djavax.management.builder.initial=com.sun.enterprise.v3.admin.AppServerMBeanServerBuilder
-XX:+UnlockDiagnosticVMOptions
-Djava.endorsed.dirs=${com.sun.aas.installRoot}/modules/endorsed${path.separator}${com.sun.aas.installRoot}/lib/endorsed
-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy
-Djava.security.auth.login.config=${com.sun.aas.instanceRoot}/config/login.conf
-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as
-Xmx512m
-Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/config/keystore.jks
-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/cacerts.jks
-Djava.ext.dirs=${com.sun.aas.javaRoot}/lib/ext${path.separator}${com.sun.aas.javaRoot}/jre/lib/ext${path.separator}${com.sun.aas.instanceRoot}/lib/ext
-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
-DANTLR_USE_DIRECT_CLASS_LOADING=true
-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.shell.remote,org.apache.felix.fileinstall
-Dosgi.shell.telnet.port=6666
-Dosgi.shell.telnet.maxconn=1
-Dosgi.shell.telnet.ip=127.0.0.1
-Dgosh.args=--nointeractive
-Dfelix.fileinstall.dir=${com.sun.aas.installRoot}/modules/autostart/
-Dfelix.fileinstall.poll=5000
-Dfelix.fileinstall.log.level=2
-Dfelix.fileinstall.bundles.new.start=true
-Dfelix.fileinstall.bundles.startTransient=true
-Dfelix.fileinstall.disableConfigSave=false
-XX:NewRatio=2
-Dcom.ctc.wstx.returnNullForDefaultNamespace=true
-XX:MaxPermSize=192m
-server
-Djava.awt.headless=true
-Djdk.corba.allowOutputStreamSubclass=true
-Djdk.tls.rejectClientInitiatedRenegotiation=true
-XX:+UnlockDiagnosticVMOptions
-Djava.endorsed.dirs=${com.sun.aas.installRoot}/modules/endorsed${path.separator}${com.sun.aas.installRoot}/lib/endorsed
-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy
-Djava.security.auth.login.config=${com.sun.aas.instanceRoot}/config/login.conf
-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as
-Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/config/keystore.jks
-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/cacerts.jks
-Djava.ext.dirs=${com.sun.aas.javaRoot}/lib/ext${path.separator}${com.sun.aas.javaRoot}/jre/lib/ext${path.separator}${com.sun.aas.instanceRoot}/lib/ext
-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
-DANTLR_USE_DIRECT_CLASS_LOADING=true
-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-XX:NewRatio=2
-Xmx512m
-Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.fileinstall
-Dosgi.shell.telnet.port=${OSGI_SHELL_TELNET_PORT}
-Dosgi.shell.telnet.maxconn=1
-Dosgi.shell.telnet.ip=127.0.0.1
-Dgosh.args=--noshutdown -c noop=true
-Dfelix.fileinstall.dir=${com.sun.aas.installRoot}/modules/autostart/
-Dfelix.fileinstall.poll=5000
-Dfelix.fileinstall.log.level=3
-Dfelix.fileinstall.bundles.new.start=true
-Dfelix.fileinstall.bundles.startTransient=true
-Dfelix.fileinstall.disableConfigSave=false