卢布兑美元走势:将jboss做成windows服务

来源:百度文库 编辑:中财网 时间:2024/04/30 05:55:58
Community > JBoss AS > 文档
取决于 JBoss AS 中的文档

RunJBossAsAServiceOnWindows

版本 57  创建于: 2004-2-15 下午8:46 作者 unknownMigrationUser - 最后修改:  2008-10-2 上午6:46 作者 Shaun Appleton

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 theJavaServiceWrapper 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.execopy WRAPPER_HOME\lib\Wrapper.DLL %JBOSS_HOME%\lib\Wrapper.DLLcopy WRAPPER_HOME\lib\wrapper.jar %JBOSS_HOME%\lib\wrapper.jarmkdir %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/javawrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleAppwrapper.java.classpath.1=%JBOSS_HOME%/lib/wrapper.jarwrapper.java.classpath.2=%JAVA_HOME%/bin/java/lib/tools.jarwrapper.java.classpath.3=./run.jarwrapper.java.library.path.1=%JBOSS_HOME%/lib# these are the JAVA_OPTSwrapper.java.additional.1=-server# enviroment variables - define the ones that match your desired environmentwrapper.java.additional.2=-Denviromnment.variable=value# memory parameters - define the ones that match your desired environmentwrapper.java.additional.3=-Xms64mwrapper.java.additional.4=-Xmx96m# If you need serialization suppport wrapper.java.additional.5=-Dsession.serialization.jboss=truewrapper.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 configswrapper.app.parameter.2=-c YOURCONFIG# Define listening IP - If you have more than one IP or want to indicate to listen on a specific IPwrapper.app.parameter.3=-b aaa.bbb.ccc.ddd# wrapper log locationwrapper.logfile=%JBOSS_HOME%/server/YOURCONFIG/log/wrapper.log# You must not change below parameters without first uninstall the service# service namewrapper.ntservice.name=JbossYOURCONFIG# service display namewrapper.ntservice.displayname=JBoss Server YOURCONFIG

 

Test the service:

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

Install the service:

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

Uninstall the service:

cd %JBOSS_HOME%\binwrapper.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 :

 

            

 

-


 

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:

  • Sun JVM Options

  • Revalations on Java signal handling

 

 

Referenced by: