How to Run Asadmin Commands in Embedded GlassFish
By ByronNevins on Feb 27, 2009
You can leverage your experience and knowledge about the GlassFish command line tool, asadmin, with Embedded GlassFish servers.
Here is a use case:
You want an Embedded GlassFish server that uses a JavaDB database. You need to setup a few things in the server configuration. You can do this configuration in your code every time you start using the CommandExecutor. Another possibility is to do the following:
- start the Embedded GlassFish server -- making sure autodelete is off
- Run asadmin commands for configurationmbedded GlassFish server
- Stop the Embedded GlassFish server
- Always set the install-root to the root of the generated file system from steps 1,2.
Here is how to run asadmin in Embedded GlassFish (embedded.jar is the Embedded GlassFish all-in-one jar file that you have downloaded or built)
java -cp final.jar com.sun.enterprise.admin.cli.AsadminMain %\*
java -cp final.jar com.sun.enterprise.admin.cli.AsadminMain $\*