Friday, August 27, 2010

Installing GlassFish as a windows service

I would think installing GlassFish as a service is a fairly common requirement, however I battled to find any concise documentation on how to do this, so here's my bash.

I'm going to assume the following:
  • GlassFish is installed to c:\GlassFishv3
  • The GlassFish bin directory has been added to your path (c:\GlassFishv3\bin)
  • GlassFish 3.0.1
right now down to it, run the following statement:
asadmin create-service



















Easy enough, but I don't like the service name domain1 - as it is rather uninformative, I would much prefer a name like say GlassFish


cd glassfishv3\glassfish\domains\domain1\bin
notepad domain1Service.xml

This shows a file something like this



  domain1
  domain1 GlassFish Server
  GlassFish Server
  C:/glassfishv3/glassfish/bin/asadmin.bat
  C:/glassfishv3/glassfish/domains/domain1/bin
  reset
  tcpip
  start-domain
  --verbose
  --domaindir
  C:/glassfishv3/glassfish/domains
  domain1
  stop-domain
  --domaindir
  C:/glassfishv3/glassfish/domains
  domain1
The important elements for us are these


  domain1
  domain1 GlassFish Server
  GlassFish Server

Lets Change them to something more friendly like


  GlassFish 3.0.1
  GlassFish 3.0.1
  GlassFish 3.0.1 Server
Or whatever fits your needs.
Right now to round it off, run the thiese last 2 commands
Cd glassfish\3.0.1\glassfish\domains\domain1\bin
domain1Service.exe uninstall
domain1Service.exe install

You now have GlassFish installed with a service name of your choosing.

3 comments:

  1. Thanks a lot. However, I didn't have a domain1Service.xml until after I created the service. Otherwise, great post!

    ReplyDelete