Deploying Applications to GlassFish Using curl
Thursday, Feb 10, 2011 |Deploying Applications to GlassFish Using curl
Jason Lee 2011-02-10
curl -s -S \
-H 'Accept: application/json' -X POST \
-H 'X-Requested-By: dummy' \
-F id=@/path/to/application.war \
-F force=true http://localhost:4848/management/domain/applications/application
Remember that the actual archive contents are passed as the value to the parameter id
, so we tell curl
to send the contents of the file using the prefix @
. The context root and application will be deduced by the system (or can be specified by passing contextroot
and name
parameters). The force
parameter tells GlassFish to force the deployment even if an application is already deployed under that name (which is effectively a redeployment). As an added bonus, to undeploy, you can issue this:
curl -s -S \
-H 'Accept: application/json' \
-H 'X-Requested-By: dummy' \
-X DELETE http://localhost:4848/management/domain/applications/application/$APPNAME
It's as simple as that. If you're using a shell script, you could always just use asadmin directly, of course. Using that approach, asadmin must be on the PATH, or you have to specify the full path in your script, so your choice comes down to preference, I think. Either way, now you know how to do both. :)