Jul 16, 2007

[AS] JBoss AS 4.2.0 の Windows サービス化にチャレンジ

JBoss AS 4.2.0 を Windows サービスとして登録する方法をメモ。 Getting Started with JBoss 4.0Running as a Service の情報が古く、少々戸惑ったが Java Service Wrapper を使用することで無事 JBoss AS 4.2.0 を Windows サービスとして登録できた。

Java Service Wrapper
http://wrapper.tanukisoftware.org/doc/english/integrate-simple-win.html
RunJBossAsAServiceOnWindows
http://jboss.org/wiki/Wiki.jsp?page=RunJBossAsAServiceOnWindows
Running Jboss as a Windows Service
http://www.theserverside.com/discussions/thread.tss?thread_id=21279

Java Service Wrapper を JBoss AS 4.2.0 にコピー

まず、Java Service Wrapper を %JBOSS_HOME% にコピーする。

> copy %WRAPPER_HOME%\bin\Wrapper.exe %JBOSS_HOME%\bin\
> copy %WRAPPER_HOME%\src\bin\App.bat.in %JBOSS_HOME%\bin\
> move %JBOSS_HOME%\bin\App.bat.in %JBOSS_HOME%\bin\JBoss.bat
> copy %WRAPPER_HOME%\src\bin\InstallApp-NT.bat.in %JBOSS_HOME%\bin\
> move %JBOSS_HOME%\bin\InstallApp-NT.bat.in %JBOSS_HOME%\bin\InstallJBoss-NT.bat
> copy %WRAPPER_HOME%\src\bin\UninstallApp-NT.bat.in %JBOSS_HOME%\bin\
> move %JBOSS_HOME%\bin\UninstallApp-NT.bat.in %JBOSS_HOME%\bin\UninstallJBoss-NT.bat
> copy %WRAPPER_HOME%\lib\Wrapper.DLL %JBOSS_HOME%\lib\
> copy %WRAPPER_HOME%\lib\wrapper.jar %JBOSS_HOME%\lib\
> md %JBOSS_HOME%\conf
> copy %WRAPPER_HOME%\src\conf\wrapper.conf.in %JBOSS_HOME%\conf\
> move %JBOSS_HOME%\src\conf\wrapper.conf.in %JBOSS_HOME%\conf\wrapper.conf

Java Service Wrapper の設定

%JBOSS_HOME%\conf\wrapper.conf を編集する。

#********************************************************************
# Wrapper Properties
#********************************************************************
# Java Application
wrapper.java.command=c:/jdk1.5.0_12/bin/java

# Java Main class.  This class must implement the WrapperListener interface
#  or guarantee that the WrapperManager class is initialized.  Helper
#  classes are provided to do this for you.  See the Integration section
#  of the documentation for details.
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=c:/jboss-4.2.0.GA/lib/wrapper.jar
wrapper.java.classpath.2=c:/jdk1.5.0_12/lib/tools.jar
wrapper.java.classpath.3=./run.jar

# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=c:/jboss-4.2.0.GA/lib

# Java Additional Parameters
wrapper.java.additional.1=-server

# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=3

# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=64

# Application parameters.  Add parameters as needed starting from 1
wrapper.app.parameter.1=org.jboss.Main
wrapper.app.parameter.2=-b 0.0.0.0

#********************************************************************
# Wrapper Logging Properties
#********************************************************************
# Format of output for the console.  (See docs for formats)
wrapper.console.format=PM

# Log Level for console output.  (See docs for log levels)
wrapper.console.loglevel=INFO

# Log file to use for wrapper output logging.
wrapper.logfile=c:/jboss-4.2.0.GA/server/default/log/wrapper.log

# Format of output for the log file.  (See docs for formats)
wrapper.logfile.format=LPTM

# Log Level for log file output.  (See docs for log levels)
wrapper.logfile.loglevel=INFO

# Maximum size that the log file will be allowed to grow to before
#  the log is rolled. Size is specified in bytes.  The default value
#  of 0, disables log rolling.  May abbreviate with the 'k' (kb) or
#  'm' (mb) suffix.  For example: 10m = 10 megabytes.
wrapper.logfile.maxsize=0

# Maximum number of rolled log files which will be allowed before old
#  files are deleted.  The default value of 0 implies no limit.
wrapper.logfile.maxfiles=0

# Log Level for sys/event log output.  (See docs for log levels)
wrapper.syslog.loglevel=NONE

#********************************************************************
# Wrapper Windows Properties
#********************************************************************
# Title to use when running as a console
wrapper.console.title=JBoss Server

#********************************************************************
# Wrapper Windows NT/2000/XP Service Properties
#********************************************************************
# WARNING - Do not modify any of these properties when an application
#  using this configuration file has been installed as a service.
#  Please uninstall the service before modifying this section.  The
#  service can then be reinstalled.

# Name of the service
wrapper.ntservice.name=JBoss

# Display name of the service
wrapper.ntservice.displayname=JBoss Server

# Description of the service
wrapper.ntservice.description=JBoss Server

# Service dependencies.  Add dependencies as needed starting from 1
wrapper.ntservice.dependency.1=

# Mode in which the service is installed.  AUTO_START or DEMAND_START
wrapper.ntservice.starttype=AUTO_START

# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=false
Java Service Wrapper の JMX サービスを JBoss AS に登録

%JBOSS_HOME%\server\default\deploy\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 code="org.tanukisoftware.wrapper.jmx.WrapperManagerTesting"
           name="JavaServiceWrapper:service=WrapperManagerTesting"/>
</server>

JBoss AS 4.2.0 を Windows サービスとして登録

> cd %JBOSS_HOME%\bin
> InstallJBoss-NT.bat
  

JBoss AS 4.2.0 の起動と停止

起動は下記のコマンドで行う。

> net start JBoss
停止は下記のコマンドで行う。
> net stop JBoss

Posted in AS | このエントリーをはてなブックマークに追加 | この記事をクリップ! livedoor クリップ |