JBossNativeWindows

Using JBoss Native to run JBoss AS as a Windows Service

 

JBoss AS comes with Windows service executable as part of JBossNative

that can run JBoss Application Server as service.

The service executable jbosssvc.exe transforms the run.bat and

shutdown.bat batch scripts to services. This means that any change

made to those scripts will be used both in service and command

line mode.

 

 

There are other options for running JBoss as a service in windows.

 

Download

JBoss Native is available from the JBoss download area.

 

Install

To install the JBoss Application Server as Windows service use

the provided service.bat batch file.

C:\> cd c:\jboss-4.2.0\bin
C:\> service.bat install

 

Start

To start the JBoss Application Server as Windows service use Control pannel

or net start command. When running in service mode the console output is

redirected to the file run.log. You can inspect the file for any errors

during service startup.

 

C:\> net start JBAS4SVC
  The JBoss Application Server 4.2 service is starting.
  The JBoss Application Server 4.2 service was started successfully.

 

Stop

To stop the JBoss Application Server as Windows service use Control pannel

or net stop command. When running in service mode the console output

is redirected to the file shutdown.log. You can inspect the file for

any errors during service shutdown.

 

C:\> net stop JBAS4SVC
  The JBoss Application Server 4.2 service was stopped successfully.

 

Restart

To restart the JBoss Application Server as Windows service use Control pannel.

 

 

 

 

You'll need to reboot windows for the service to disappear from the Services snap-in

 

Uninstall

To remove the JBoss Application Server as Windows service use the provided

service.bat batch file.

 

C:\> cd c:\jboss-4.2.0\bin
C:\> service.bat uninstall

 

Customization

Service customization is done by editing the service.bat script.

Each command has a separate section that you can customize. The most

common customization task would be changing service names if more then

one service instances per box are required.

 

 

 

See JBossSVC.exe for options.

jbosssvc -- program for running batch files as services.

Usage: jbosssvc -i        service service.bat
                -i[wdcl]  service workingpath description comment
                          service.bat
                -u        service
                -t        service
Options:
   -d   Service display name
   -c   Service description
   -w   Service working path
   -l   Turn info logging On

 

Available Builds

JBossNativeBuilds

 

-


 

Notes{FOOTNOTE DEF 1 1}

 

Thread dumps

 

Running as a service makes it more difficult to generate a thread dump. Here are some workarounds for the problem

 

Mysterious shutdowns

 

Some users have reported JBoss experiencing clean shutdowns while running as a service.  It turns out that the Sun JVM monitors for SIGHUP and interprets it as a signal to shut down, so this can occur anytime the console user logs out of the system.  To prevent this from happening, you should add this flag to your JVM parameters:

 

-Xrs Reduces use of operating-system signals by the Java virtual machine (JVM). This option is available beginning with J2SE 1.3.1. In J2SE 1.3.0, the Shutdown Hooks facility was added to allow orderly shutdown of a Java application. The intent was to allow user cleanup code (such as closing database connections) to run at shutdown, even if the JVM terminates abruptly.

 

Sun's JVM catches signals to implement shutdown hooks for abnormal JVM termination. The JVM uses SIGHUP, SIGINT, and SIGTERM to initiate the running of shutdown hooks.

 

The JVM uses a similar mechanism to implement the pre-1.2 feature of dumping thread stacks for debugging purposes. Sun's JVM uses SIGQUIT to perform thread dumps.

 

Applications embedding the JVM frequently need to trap signals like SIGINT or SIGTERM, which can lead to interference with the JVM's own signal handlers. To address this issue, the -Xrs command-line option has been added beginning in J2SE 1.3.1. When -Xrs is used on Sun's JVM, the signal masks for SIGINT, SIGTERM, SIGHUP, and SIGQUIT are not changed by the JVM, and signal handlers for these signals are not installed.

 

Don't rename service.bat

The batch file service.bat must not be renamed, otherwise you'll get a message after starting the service that the service was stopped after starting.

 

Notes{FOOTNOTE DEF 2 2}

Using Sun's JVM - if you have a PATH environment variable that ends with a "\" then the service will not start. In the following example, the command produced in run.bat fails because QuickTime appended a path of "...\QTSystem\" at the end of the path. The solution is to delete the trailing "\" from the PATH in Windows System settings.

"C:\Java\bin\java"  -Djava.library.path="C:\Java\jboss\bin\native;D:\Misys\Insight\Bin;C:\Java\bin;C:\Java\Jboss\bin;c:\java\ant\bin;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Symantec\pcAnywhere\;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;c:\java\tomcat55\bin;C:\Java\xmlbeans\bin;C:\Program Files\QuickTime\QTSystem\" -Dprogram.name=run.bat -server -Xms128m -Xmx512m -Xrs -Dsun.rmi.dgc.client.gcInterval=3600000 "-Djava.endorsed.dirs=C:\Java\jboss\lib\endorsed" -classpath "C:\Java\lib\tools.jar;C:\Java\jboss\bin\run.jar" org.jboss.Main

 

Notes{FOOTNOTE DEF 3 3}

Please re-start PC at least once for %JAVA_HOME% to take effect, if you install directly from JDK to JBoss, to let JBoss as native windows service can be installed properly.Please refer here Please follow-up the bugZilla here

-


References:

 

{FOOTNOTE RED #1 1} RunJBossAsAServiceOnWindows

 

 

 

 

Referenced by: