Running Glassfish as a service on CentOS

Here is how you run glassfish as a service on CentOS:

  1. Create a user glassfish (you can call it anything you want) under which Glassfish will run.
    #useradd glassfish
  2. Install glassfish in /home/glassfish.
  3. Create the startup script /etc/init.d/glassfish for glassfish.
  4. Install the service
    #chmod +x /etc/init.d/glassfish
    #chkconfig --add glassfish
    #chkconfig --level 3 glassfish on
  5. Start glassfish.
    #/etc/init.d/glassfish start

14 thoughts on “Running Glassfish as a service on CentOS”

  1. I think you’re missing a “-” in the line “#chkconfig -add glassfish” so that it is “#chkconfig –add glassfish”

  2. Hi, thank you for this script…

    when i enter #/etc/init.d/glassfish start, system tell me:
    CLI304 Can’t find domain.xml. It should be here: /usr/glassfishv3/glassfish/domains/domain1/config/domain.xml
    Command start-domain failed.

    If i call #asadmin start-domain domain1 from super user, glassfish run correctly

    Can you help me?

  3. Great help this script. Used it as a base. There is a little typo in the location of the startup.log it should be $GLASSFISH_HOME/glassfish/domains/domain1/logs/startup.log

  4. Ther is no domain.xml file at /usr/glassfishv3/glassfish/domains/domain1/config/
    No permission problem, the file is not there !!!
    Any sugestions ?

  5. I have a problem, I try to start glassfish

    service glassfish start

    Starting Glassfish: su: user glassfish does not exist

    Why is this problem??

Leave a Reply

Your email address will not be published. Required fields are marked *