Sun GlassFish Enterprise Server 2.1 Administration Guide

Appendix A Automatically Restarting a Domain or Node Agent

If your domain or node agent is stopped unexpectedly (for example, if you need to restart your machine), you can configure your system to automatically restart the domain or node agent.

This Appendix contains the following topics:

Restarting Automatically on Solaris 10

Solaris 10 users can use the command asadmin create-service to create a service that restarts a node agent or Domain Administration Server (DAS). The service created uses the Solaris Service Management Facility (SMF).

The process that a service starts depends on whether the service is to restart a DAS or a node agent.

The service grants to the process the privileges of the user that runs the process. When you use the command asadmin create-service to create an SMF service, the default user is the superuser. If you require a different user to run the process, specify the user in method_credential.

If your process is to bind to a privileged port of the Solaris OS, the process requires the net_privaddr privilege. The privileged ports of the Solaris OS have a port numbers less than 1024.

To determine if a user has the net_privaddr privilege, log in as that user and type the command ppriv -l | grep net_privaddr.

To run the asadmin create-service command, you must have solaris.smf.* authorization. See the useradd and usermod man pages to find out how to set the authorizations. You must also have write permission in the directory tree: /var/svc/manifest/application/SUNWappserver. Usually, the superuser has both these permissions. Additionally, the Solaris 10 administration commands such as svccfg, svcs, and auths must be available in the PATH. For complete information on running this command, see create-service(1).

The syntax is as follows:

asadmin create-service [--name service-name] [--type das|node-agent]
--passwordfile password-file [--serviceproperties serviceproperties] 

    For example, to create a service called domain1 for domain1:

  1. Run the following:

    asadmin create-service --type das --passwordfile password.txt /appserver/domains/domain1

    This creates a service to restart the domain domain1 automatically. In the background, the command creates a manifest file from a template, validates the file, and imports it as a service.

    Note –

    If a particular Enterprise Server domain should not have default user privileges, modify the service's manifest and reimport the service. To determine a user's privileges, log in as that user and type the command ppriv -l.

  2. Once the service is created, enable it using the svacdm enable command:

    svacdm enable /appserver/domains/domain1

  3. Once enabled, if the domain goes down, SMF restarts it.

As you administer your service, the following Solaris commands are useful:

For more information on these commands, see the command manpages.

Restarting Automatically Using inittab on Solaris 9 and Linux Platforms

To restart your domain on the Solaris 9 or Linux platform, add a line of text to the /etc/inittab file.

If you use /etc/rc.local, or your system’s equivalent, place a line in /etc/rc.local that calls the desired asadmin command.

For example, to restart domain1 for an Enterprise Server installed in the opt/SUNWappserver directory, using a password file called password.txt:

das:3:respawn:/opt/SUNWappserver/bin/asadmin start-domain --user admin 
--passwordfile /opt/SUNWappserver/password.txt domain1

Put the text on one line. The first three letters are a unique designator for the process and can be altered.

To restart a node agent, the syntax is similar. For example, to restart agent1 for an Enterprise Server installed in the opt/SUNWappserver directory, using a password file called password.txt:

das:3:respawn:/opt/SUNWappserver/bin/asadmin start-node-agent --user admin 
--passwordfile /opt/SUNWappserver/password.txt agent1

Restarting Automatically on the Microsoft Windows Platform

To restart automatically on Microsoft Windows, create a Windows Service and prevent the service from shutting down when a user logs out.

Creating a Windows Service

Use the appservService.exe and appserverAgentService.exe executable files shipped with the Sun GlassFish Enterprise Server in conjunction with the Service Control command (sc.exe) provided by Microsoft.

The sc.exe command comes with Windows XP and is in the system32 subdirectory of the Windows installation directory (usually either C:\windows\system32 or C:\winnt\system32). As of this writing, the Windows 2000 sc.exe is available for download at For more information on using sc.exe, see

Use appservService.exe and appservAgentService.exe as follows:

C:\winnt\system32\sc.exe create service-name binPath= \"fully-qualified-path-to-appservService.exe 
\"fully-qualified-path-to-asadmin.bat start-command\" 
\"fully-qualified-path-to-asadmin.bat stop-command\"" 
start= auto DisplayName= "display-name"

Note –

There is no space between binpath and the equals sign (=). There must be a space after the equals sign and before the path.

For example, to create a service called SunJavaSystemAppServer DOMAIN1 that starts and stops the domain domain1, using a password file C:\Sun\AppServer\password.txt:

C:\windows\system32\sc.exe create domain1 binPath= 
"C:\Sun\AppServer\lib\appservService.exe \"C:\Sun\AppServer\bin\asadmin.bat 
start-domain --user admin --passwordfile C:\Sun\AppServer\password.txt domain1\" 
\"C:\Sun\AppServer\bin\asadmin.bat stop-domain domain1\"" start= auto 
DisplayName= "SunJavaSystemAppServer DOMAIN1"

To create a service that starts and stops the node agent agent1:

C:\windows\system32\sc.exe create agent1 binPath= 
"C:\Sun\AppServer\lib\appservAgentService.exe \"C:\Sun\AppServer\bin\asadmin.bat 
start-node-agent --user admin --passwordfile C:\Sun\AppServer\password.txt agent1\" 
\"C:\Sun\AppServer\bin\asadmin.bat stop-node-agent agent1\"" start= auto 
DisplayName= "SunJavaSystemAppServer AGENT1"

Note –

The start and stop commands entered as part of the binPath= parameter must have the correct syntax. To test, run the commands from the command prompt. If the commands do not properly start or stop the domain or node agent, the service does not work correctly.

Note –

Don’t use a mixture of asadmin start and stop commands and service start and stops. Mixing the two can cause the server status to be out of sync. For example, the service might not show that the component has started even though the component is not running. To avoid this situation, always use the sc.exe command to start and stop the component when using services.

If your sc.exe create command did not properly create the service, delete the service and try again. To delete the service, use the sc.exe delete "service-name" command.

Preventing the Service From Shutting Down When a User Logs Out

By default, the Java VM catches signals from Windows that indicate that the operating system is shutting down, or that a user is logging out, and shuts itself down cleanly. This behavior causes the Enterprise Server service to shut down when a user logs out of Windows. To prevent the service from shutting down when a user logs out, set the -Xrs Java VM option.

To set the -Xrs Java VM option, add the following line to the section of the as-install\domains\domain-name\config\domain.xml file that defines Java VM options:


If the Enterprise Server service is running, stop and restart the service for your changes to become effective.

Note –

In some Windows 2003 Server installations, adding the -Xrs option to the domain.xml file fails to prevent the service from shutting down. In this situation, add the option to the as-install\lib\processLauncher.xml file as follows:

<process name="as-service-name">
   <sysproperty key="-Xrs"/>

Security for Automatic Restarts

If you are using the cluster or enterprise profile, the administration passworda and master password are required when automatically restarting Enterprise Server. If you are using the Developer Profile, no

Handle the password and master password requirements for cluster and enterprise profiles in one of the following ways: