Deploy to remote Glassfish instance via cli

╄→尐↘猪︶ㄣ 提交于 2019-12-01 07:31:54

After doing a bit more research I gave up on trying to install asadmin without the full Glassfish installation and instead used Glassfish's REST admin interface.

I now made it work using CURL in a simple batch file:

curl.exe ^
    --user glassfish_username:glassfish_password ^
    --insecure ^
    -H "Accept: application/json" ^
    -H "X-Requested-By: dummy" ^
    -X POST ^
    -F id=@yourfile.war ^
    -F contextroot=yourcontextroot ^
    -F force=true ^
    https://yourservername:4848/management/domain/applications/application/

The REST API is fairly straight forward once you know what you need to do but just in case somebody else needs this, here a couple of important points:

  • --insecure is required (by CURL) to allow self-signed and untrusted SSL certificates
  • The header attributes for "Accept" and "X-Requested-By" must be set, otherwise Glassfish doesn't process the request and simply returns a blank document as an ansower. No idea why but setting these parameters made it work.
  • The content of the war file is passed as the "id" parameter on the POST
  • The URL needs to be exactly as shown in the snipped above, i.e. do not replace "domain" with your domain name or "application" with your application name. This is the actual REST interface endpoint. There is no need to specify the domain/application name anywhere.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!