A lot of people experiment GlassFish for the first time via an IDE (most likely NetBeans, but maybe also with Eclipse) and feel a bit lost when it comes to use GlassFish without the tool driving it for them. So here are a few (mostly basic) CLI asadmin hints for GlassFish v3 :

* Start/Stop *
Start GlassFish (need this to access the admin console on default port http://localhost:4848) :
% GLASSFISH_HOME/bin/asadmin start-domain (assumes there's only one domain)
% asadmin start-domain domain1 (explicitly reference a given domain)
% asadmin start-domain -v domain (will cause the log to be dumped to the standard output)
% java -jar modules/glassfish.jar (may be useful in certain circumstance (explicit java version for instance)

Stop GlassFish :
% asadmin stop-domain {domain1}

List existing instances (including stopped/started status)
% asadmin list-domains

You can also create additional domains with % asadmin create-domain ... (and I would suggest using the -portbase option).

* Resources *
If the IDE has created connection pools and datasources, you will certainly find the following create-jdbc-connection-pool and create-jdbc-resource commands useful. Note also that asadmin has a "closest match" feature for misspelled commands and extensive online documentation :
% ~/glassfishv3/bin/asadmin create
CLI001 Invalid Command: create
Closest matching local and remote command(s):
create-admin-object
create-audit-module
create-auth-realm
create-connector-connection-pool
create-connector-resource
create-connector-security-map
create-connector-work-security-map
create-custom-resource
create-domain
create-file-user
create-http
create-http-listener
create-iiop-listener
create-javamail-resource
create-jdbc-connection-pool
create-jdbc-resource
create-jms-host
create-jms-resource
create-jmsdest
create-jndi-resource
create-jvm-options
create-lifecycle-module
create-message-security-provider
create-network-listener
create-password-alias
create-profiler
create-protocol
create-resource-adapter-config
create-resource-ref
create-service
create-ssl
create-system-properties
create-threadpool
create-transport
create-virtual-server

Almost every bits of configuration is located in the glassfish/domains/domain1/config/domain.xml config file but you really should be using asadmin or the admin console and not edit this by hand.

* (auto)deployment *
The explicit deployment is based on the asadmin deploy app.{ear|war|jar} command. Listing deployed applications is as easy as asadmin list-application (notice how GlassFish tells you which containers are at work for a given app), and undeployment simply requires a asadmin undeploy app-name.

While these commands have lots of options (asadmin deploy --help for details), you may find it convenient to simply drop your application in the domain1/autodeploy directory. Deleting the file will trigger the undeployment.

All the details for the asadmin CLI can be found in the official "Using the asadmin Utility" documentation.



More...