JavaOne Session Report: “50 Tips in 50 Minutes for GlassFish Fans”

Posted by Janice J. Heiss on Oracle Blogs See other posts from Oracle Blogs or by Janice J. Heiss
Published on Fri, 5 Oct 2012 01:30:39 +0000 Indexed on 2012/10/05 3:45 UTC
Read the original article Hit count: 255

Filed under:

At JavaOne 2012 on Monday, Oracle’s Engineer Chris Kasso, and Technology Evangelist Arun Gupta, presented a head-spinning session (CON4701) in which they offered 50 tips for GlassFish fans. Kasso and Gupta alternated back and forth with each presenting 10 tips at a time. An audience of about (appropriately) 50 attentive and appreciative developers was on hand in what has to be one of the most information-packed sessions ever at JavaOne!

Aside: I experienced one of the quiet joys of JavaOne when, just before the session began, I spotted Java Champion and JavaOne Rock Star Adam Bien sitting nearby – Adam is someone I have been fortunate to know for many years.

GlassFish is a freely available, commercially supported Java EE reference implementation.

The session prioritized quantity of tips over depth of information and offered tips that are intended for both seasoned and new users, that are meant to increase the range of functional options available to GlassFish users. The focus was on lesser-known dimensions of GlassFish. Attendees were encouraged to pursue tips that contained new information for them.

All 50 tips can be accessed here.

Below are several examples of more elaborate tips and a final practical tip on how to get in touch with these folks.

Tip #1: Using the login Command

* To execute a remote command with asadmin you must provide the admin's user name and password.
* The login command allows you to store the login credentials to be reused in subsequent commands.
* Can be logged into multiple servers (distinguish by host and port).

Example:
     % asadmin --host ouch login
     Enter admin user name [default: admin]>
     Enter admin password>
     Login information relevant to admin user name [admin]
     for host [ouch] and admin port [4848] stored at
     [/Users/ckasso/.asadminpass] successfully.
     Make sure that this file remains protected.
     Information stored in this file will be used by
     asadmin commands to manage the associated domain.
     Command login executed successfully.
     % asadmin --host ouch list-clusters
     c1 not running
     Command list-clusters executed successfully.

Tip #4: Using the AS_DEBUG Env Variable

* Environment variable to control client side debug output
* Exposes:

  • command processing info
  • URL used to access the command:                           http://localhost:4848/__asadmin/uptime
  • Raw response from the server


Example:
   % export AS_DEBUG=true
  % asadmin uptime
  CLASSPATH= ./../glassfish/modules/admin-cli.jar
  Commands: [uptime]
  asadmin extension directory: /work/gf-3.1.2/glassfish3/glassfish/lib/asadm    
  ------- RAW RESPONSE  ---------
   Signature-Version: 1.0
   message: Up 7 mins 10 secs
   milliseconds_value: 430194
   keys: milliseconds
   milliseconds_name: milliseconds
   use-main-children-attribute: false
   exit-code: SUCCESS
  ------- RAW RESPONSE  ---------

Tip #11: Using Password Aliases

* Some resources require a password to access (e.g. DB, JMS, etc.).
* The resource connector is defined in the domain.xml.

Example:
Suppose the DB resource you wish to access requires an entry like this in the domain.xml:
     <property name="password" value="secretp@ssword"/>

But company policies do not allow you to store the password in the clear.
* Use password aliases to avoid storing the password in the domain.xml
* Create a password alias:
     % asadmin create-password-alias DB_pw_alias
     Enter the alias password>
     Enter the alias password again>
     Command create-password-alias executed successfully.

* The password is stored in domain's encrypted keystore.
* Now update the password value in the domain.xml:
     <property name="password" value="${ALIAS=DB_pw_alias}"/>

Tip #21: How to Start GlassFish as a Service

* Configuring a server to automatically start at boot can be tedious.
* Each platform does it differently.
* The create-service command makes this easy.  

  • Windows: creates a Windows service
  • Linux: /etc/init.d script
  • Solaris: Service Management Facility (SMF) service

* Must execute create-service with admin privileges.
* Can be used for the DAS or instances
* Try it first with the --dry-run option.
* There is a (unsupported) _delete-server

Example:
     # asadmin create-service domain1
     The Service was created successfully. Here are the details:
     Name of the service:application/GlassFish/domain1
     Type of the service:Domain
     Configuration location of the service:/work/gf-3.1.2.2/glassfish3/glassfish/domains
     Manifest file location on the system:/var/svc/manifest/application/GlassFish/domain1_work_gf-3.1.2.2_glassfish3_glassfish_domains/Domain-service-smf.xml.
     You have created the service but you need to start it yourself.

Here are the most typical Solaris commands of interest:
     * /usr/bin/svcs  -a | grep domain1  // status
     * /usr/sbin/svcadm enable domain1 // start
     * /usr/sbin/svcadm disable domain1 // stop
     * /usr/sbin/svccfg delete domain1 // uninstall

Tip #34: Posting a Command via REST

* Use wget/curl to execute commands on the DAS.

Example:  Deploying an application
   % curl -s -S \
       -H 'Accept: application/json' -X POST \
       -H 'X-Requested-By: anyvalue' \
       -F id=@/path/to/application.war \
       -F force=true http://localhost:4848/management/domain/applications/application

* Use @ before a file name to tell curl to send the file's contents.
* The force option tells GlassFish to force the deployment in case the application is already deployed.
* Use wget/curl to execute commands on the DAS.

Example:  Deploying an application
   % curl -s -S \
       -H 'Accept: application/json' -X POST \
       -H 'X-Requested-By: anyvalue' \
       -F id=@/path/to/application.war \
       -F force=true http://localhost:4848/management/domain/applications/application

* Use @ before a file name to tell curl to send the file's contents.
* The force option tells GlassFish to force the deployment in case the application is already deployed.

Tip #46: Upgrading to a Newer Version

* Upgrade applications and configuration from an earlier version
* Upgrade Tool: Side-by-side upgrade
– GUI: asupgrade
– CLI: asupgrade --c
– What happens ?
* Copies older source domain -> target domain directory
* asadmin start-domain --upgrade
* Update Tool and pkg: In-place upgrade
– GUI: updatetool, install all Available Updates
– CLI: pkg image-update
– Upgrade the domain
* asadmin start-domain --upgrade

Tip #50: How to reach us?
* GlassFish Forum: http://www.java.net/forums/glassfish/glassfish
* [email protected]
* @glassfish
* facebook.com/glassfish
* youtube.com/GlassFishVideos
* blogs.oracle.com/theaquarium

Arun Gupta acknowledged that their method of presentation was experimental and actively solicited feedback about the session. The best way to reach them is on the GlassFish user forum.

In addition, check out Gupta’s new book Java EE 6 Pocket Guide.

© Oracle Blogs or respective owner

Related posts about /JavaOne 2012