This blog is about my observations and thoughts related to software development. These observations include tips and tricks that I have learned, solutions to problems I have faced, and other concepts I have found interesting and useful. This blog is intended to provide information to help other developers facing the same issues as well as providing me a method to document things in a well-known location for my own future reference.
GlassFish Admin Console
GlassFish's web-based Admin Console GUI is probably the best-known interface for GlassFish administration. By default, it is accessed via the URL
http://localhost:4848/ once GlassFish is running. The two screen snapshots below provide a taste of this approach, but I don't look any deeper at this option here as this is a fairly easy to understand interface that is fairly easy to learn and use once logged into the website.
GlassFish Admin Command Line Interface
The GlassFish Admin Console GUI offers advantages of a GUI such as ease of learning and using, but also comes with the drawbacks of a GUI (can take longer to get through the "overhead" of using the GUI approach for things that are easily done from the command line and does not work as well in scripts and headless environments). In some cases, a command-line approach is preferred and GlassFish supports command-line administration with the GlassFish Admin Command Line Interface.
asadmin start-domain is used to start a Domain in GlassFish. The command
asadmin help can be used to learn more about the available commands. A very small snippet from the top of this help output is shown next:
Utility Commands asadmin(1m)
asadmin - utility for performing administrative tasks for
Oracle GlassFish Server
asadmin [--host host]
[subcommand [options] [operands]]
Use the asadmin utility to perform administrative tasks for
Oracle GlassFish Server. You can use this utility instead of
the Administration Console interface.
As the beginning of the
asadmin help indicates, the
asadmin utility is an alternative to the GUI-based "Administration Console interface."
There are numerous sub-commands available and some of those are listed here:
deployand other deployment subcommands
versionto see version of GlassFish (shown in the screen snapshot below)
Additional information regarding the GlassFish Admin Command Line Interface is available in Learning GlassFish v3 Command Line Administration Interface (CLI).
The two approaches shown in this post so far for monitoring and managing GlassFish (web-based Admin Console GUI and GlassFish Admin Command Line Interface) are specific to GlassFish. GlassFish also supports monitoring and management via Java Management Extensions (JMX), including JSR 77 ("J2EE Management") as I have blogged about before in my post Simple Remote JMX with GlassFish.
Because GlassFish supports a JMX interface, it can be easily monitored and managed with readily available tools such as JConsole and JVisualVM. Besides the MBeans that GlassFish exposes itself, the JVM has built-in MBeans since J2SE 5 that can be monitored in relation to the hosted GlassFish instances as well.
The next set of images demonstrates using JConsole to view MBeans exposed via GlassFish and the JVM. The first image shows the standard JVM Platform MBeans available and the images following that one show GlassFish-specific MBeans including the
jmxremote domains. When the
bootAMX operation of the
boot-amx MBean (
amx-support domain) is clicked on that latter MBean, the full complement of AMX MBeans is available as shown in the remainder of the images.
The Oracle GlassFish Server 3.1 Administration Guide includes a section called "Using REST Interfaces to Administer GlassFish Server" that states that the "GlassFish Server provides representational state transfer (REST) interfaces to enable you to access monitoring and configuration data for GlassFish Server." It goes on to suggest that clients applications such as web browsers, cURL, and GNU Wget can be used to interact with GlassFish via the Jersey-based REST interfaces. Of course, as this page also points out, any tool written in any language that handles REST-based interfaces can be used in conjunction with GlassFish's REST support.
Not surprisingly, the GlassFish REST APIs are exposed via URLs over HTTP. The previously cited Admin Guide states that configuration/management operations are accessed via URLs of form
http://host:port/management/domain/path and monitoring operations are accessed via URLs of form
One of the easiest ways to use GlassFish's REST interfaces is via web browser using the URLs mentioned earlier (http://localhost:4848/management/domain/ and http://localhost:4848/monitoring/domain/ for example). The next three screen snapshots attempt to give a taste of this style of access. The middle image shows that the monitoring needs to be enabled in GlassFish.
Using a web browser to interact with GlassFish for management and monitoring is easy, but this can be done with the Web Admin Console I covered at the beginning of this blog post. The real advantage of the REST-based interface is the ability to call it from other client tools, especially custom-built tools and scripts. For example, one can write scripts in Groovy, Python, Ruby, and other scripting languages to interact with GlassFish. Like GlassFish's JMX-exposed APIs, GlassFish's REST-exposed APIs allow custom scripts and tools to be used or even written to manage and monitor GlassFish.
Jason Lee has posted several posts on using GlassFish's REST management/monitoring APIs such as RESTful GlassFish Monitoring, Deploying Applications to GlassFish Using curl, and GlassFish Administration: The REST of the Story.
GlassFish provides several Ant tasks that allow Ant to be used for starting and stopping the GlassFish server, for deploying applications, and for performing other management tasks. A StackOverflow Thread covers this approach. The next two screen snapshots demonstrate using the GlassFish Web Admin Console's Update Tool -> Available Add-Ons feature to select the Ant Tasks for installation and the contents of the
ant-tasks.jar that is made available upon this selection.
ant-tasks.jar JAR available, it can be placed on the Ant build's classpath to script certain GlassFish actions via an Ant build.
The ability to manage and monitor an application server is one of its highly important features. This post has looked at several of the most common methods GlassFish supports for its management, monitoring, and general administration.
Original posting available at http://marxsoftware.blogspot.com/ (Inspired by Actual Events)