quinta-feira, 7 de janeiro de 2010

Configurar JBoss como serviço através do JavaServiceWrapper


Despois de descompactar o arquivo, faça o seguinte:
  • Configurar os seguintes arquivos e diretórios. Onde YOURCONFIG, normalmente será default
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
  • Criar o arquivo wrapper.conf em %JBOSS_HOME%\server\YOURCONFIG\wrapper com o seguinte conteúdo. Edite e/ou comente o que for necessário.
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

  • Teste o serviço:
cd %JBOSS_HOME%\bin\
wrapper.exe -c %JBOSS_HOME%\server\YOURCONFIG\wrapper\wrapper.conf
  • Instale o serviço:
cd %JBOSS_HOME%\bin\

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

  • Desinstale o serviço: 

cd %JBOSS_HOME%\bin\
wrapper.exe -r %JBOSS_HOME%\server\YOURCONFIG\wrapper\wrapper.conf
 
Aviso: Certifique-se que a variável de ambiente JBOSS_HOME está configurada corretamente. (run.bat faz isto, mas wrapper não!)