Version 57

    How do I Run JBoss as a Service on Windows

     

    Option 1.  Use JBoss Native for Windows

    You can use JBossNative : http://labs.jboss.com/jbossweb/downloads/. Download the appropriate version based on your system and go through the README-service.txt which lists down the steps for running JBoss as a service.

     

     

     

     

    See: Available Builds

     

     

    Option 2. Use the JavaServiceWrapper by Tanuki.

     

    Note: Users keep editing this page, saying that the JavaServiceWrapper is not recommended.  This is not true.  They are confused between the JavaService and the JavaServiceWrapper.  They are two completely different products. JavaService is not recommended(for the below reasons), but JavaServiceWrapper is recommended.  The majority of JBoss users are using the JavaServiceWrapper as their way of making jboss run as a service.

     

    You can use Java Service Wrapper : http://wrapper.tanukisoftware.org/doc/english/integrate-simple-win.html and manage it by JMX : http://wrapper.tanukisoftware.org/doc/english/jmx.htmljboss

     

    Unzip the wrapper zip file, and do the following:

    copy WRAPPER_HOME\bin\Wrapper.exe %JBOSS_HOME%\bin\Wrapper.exe
    copy WRAPPER_HOME\lib\Wrapper.DLL %JBOSS_HOME%\lib\Wrapper.DLL
    copy WRAPPER_HOME\lib\wrapper.jar %JBOSS_HOME%\lib\wrapper.jar
    mkdir %JBOSS_HOME%\server\YOURCONFIG\wrapper
    

     

    Create wrapper.conf file inside %JBOSS_HOME%\server\YOURCONFIG\wrapper with the below contents:

    wrapper.java.command=D:/Java/jdk1.5.0_14/bin/java
    
    wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
    
    wrapper.java.classpath.1=%JBOSS_HOME%/lib/wrapper.jar
    wrapper.java.classpath.2=%JAVA_HOME%/bin/java/lib/tools.jar
    wrapper.java.classpath.3=./run.jar
    
    wrapper.java.library.path.1=%JBOSS_HOME%/lib
    
    # these are the JAVA_OPTS
    wrapper.java.additional.1=-server
    # enviroment variables - define the ones that match your desired environment
    wrapper.java.additional.2=-Denviromnment.variable=value
    # memory parameters - define the ones that match your desired environment
    wrapper.java.additional.3=-Xms64m
    wrapper.java.additional.4=-Xmx96m
    # If you need serialization suppport 
    wrapper.java.additional.5=-Dsession.serialization.jboss=true
    
    wrapper.app.parameter.1=org.jboss.Main
    # Parameters to be passed to the application (Jboss) 
    # Define server name (configuration) - If you need a config that is different than the "default" or need to run multiple configs
    wrapper.app.parameter.2=-c YOURCONFIG
    # Define listening IP - If you have more than one IP or want to indicate to listen on a specific IP
    wrapper.app.parameter.3=-b aaa.bbb.ccc.ddd
    # wrapper log location
    wrapper.logfile=%JBOSS_HOME%/server/YOURCONFIG/log/wrapper.log
    
    # You must not change below parameters without first uninstall the service
    # service name
    wrapper.ntservice.name=JbossYOURCONFIG
    # service display name
    wrapper.ntservice.displayname=JBoss Server YOURCONFIG
    

     

    Test the service:

    cd %JBOSS_HOME%\bin\
    wrapper.exe -c %JBOSS_HOME%\server\YOURCONFIG\wrapper\wrapper.conf
    

    Install the service:

    cd %JBOSS_HOME%\bin\
    wrapper.exe -i %JBOSS_HOME%\server\YOURCONFIG\wrapper\wrapper.conf
    

    Uninstall the service:

    cd %JBOSS_HOME%\bin\
    wrapper.exe -r %JBOSS_HOME%\server\YOURCONFIG\wrapper\wrapper.conf
    

     

    Warning: make sure your JBOSS_HOME environment var is set correctly (this is not the case if

    you haven't done that yourself): the run.bat does set this itself, but the wrapper doesn't !

     

    java-service-wrapper-service.xml :

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE server>
    <server>
        <mbean code="org.tanukisoftware.wrapper.jmx.WrapperManager"
               name="JavaServiceWrapper:service=WrapperManager"></mbean>
        
        <mbean code="org.tanukisoftware.wrapper.jmx.WrapperManagerTesting"
               name="JavaServiceWrapper:service=WrapperManagerTesting"></mbean>
    </server>
    

     

    -


     

    Notes

     

    JavaService is no longer recommended

     

    JavaService has a bug where it will not pass either Xss or XX:ThreadStackStize arguemnts to the jvm properly.  This results are that each thread stack is 1MB.  Under load this will most likely fail with an "java.lang.OutOfMemoryError: unable to create new native thread" error.  The fix for this error is to lower the thread stack size.  Since JavaService does not allow the thread stack size to be set, there will be no solution once an application has run into this error.

     

    The limit on the memory can also cause Tiles to slow down in JBoss when many applications are deployed.

     

    Thread dumps

     

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

     

    Port Conflicts

     

    Occasionally, when run JBoss as a service you may encounter port conflicts resulting in a BindException. See here for help

     

    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.  You can reference the following url, that gives you a table of the operating systems and the associated interrupts that Xrs will stop the vm from listening to. Revelations on Java signal handling

     

    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.

     

    Please see MysteriousShutdowns for more information.

     

    SrvAny utility

     

    Some of our customers also use the SrvAny utility, but we have heard that there may be conflicts with this tool if you make use of Windows Update.

     

    Windows resource kit

     

    The instructions from this Microsoft tech-note will help to install jboss as a service.  The trick is when you get to the part about editing the registry key you use this for you executable: cmd.exe /c path\run_my_jboss.bat.  Also, paths in the batch file become relative to a windows system folder so you cannot use relative path in the batch file.

    -


     

     

    References:

     

     

    Referenced by: