Difference between revisions of "Configure JBoss service"

From OpenKM Documentation
Jump to: navigation, search
Line 1: Line 1:
 +
{{TOCright}} __TOC__
 +
 +
These instructions are related to install and run JBoss 4.2.3 as a service, which means that will be launched at system boot and will closed properly on system shutdown.
 +
 +
== Running as a Linux Service ==
 
For security reasons you shouldn't run JBoss as '''root'''. It is better to create an user named openkm and run JBoss from him:
 
For security reasons you shouldn't run JBoss as '''root'''. It is better to create an user named openkm and run JBoss from him:
  
Line 70: Line 75:
 
For more info, read http://jboss.org/community/docs/DOC-11566.
 
For more info, read http://jboss.org/community/docs/DOC-11566.
  
[[Category: Installation Guide]]
+
== Running as a Windows Service ==
[[Category:OKM Network]]
+
You can install JBoss as a service in Windows platform by several ways:
 
 
----
 
 
 
 
 
== Running JBoss 4.2.3 as a Windows Service ==
 
  
Jboss recomended is using jboss '''native windows take''' a look here http://community.jboss.org/wiki/RunJBossAsAServiceOnWIndows
+
=== First method ===
 +
JBoss recomended is using jboss '''native windows take''' a look here http://community.jboss.org/wiki/RunJBossAsAServiceOnWIndows.
  
Must be downloaded '''jboss native''' in concordance with your architecture 32 bits or 64 bits http://labs.jboss.com/jbossweb/downloads/jboss-native.html
+
Must be downloaded '''jboss native''' in concordance with your architecture 32 bits or 64 bits http://labs.jboss.com/jbossweb/downloads/jboss-native.html.
  
Un compresss files into your %JBOSS_HOME%
+
Uncompress files into your %JBOSS_HOME%
  
 
If you want you can edit the service name editing the file %JBOSS_HOME%\bin\service.bat
 
If you want you can edit the service name editing the file %JBOSS_HOME%\bin\service.bat
Line 94: Line 95:
 
  service.bat install
 
  service.bat install
  
Now in your service control panel there's installed the jboss as a service. We tested it on several Windows and runs well.
+
Now in your service control panel there's installed JBoss as a service. We tested it on several Windows and runs well.
 
 
 
 
'''Other windows service installation methods explained belowe we've not been tested directly by us.'''
 
 
 
  
== second method ==
+
{{Note|Other windows service installation methods explained below we've not been tested directly by us.}}
  
1. Download JavaService-2.0.10.zip from http://download.forge.objectweb.org/javaservice/
+
=== Second method ===
 
+
# Download JavaService-2.0.10.zip from http://download.forge.objectweb.org/javaservice/
2. Extract to C:\JavaService-2.0.10
+
# Extract to C:\JavaService-2.0.10
 
+
# copy InstallJBoss.bat,UninstallJBoss.bat, JavaService.exe and JBossService.exe  to jboss bin directory. In our case C:\jboss-4.2.3.GA\
3. copy InstallJBoss.bat,UninstallJBoss.bat, JavaService.exe and JBossService.exe  to jboss bin directory. In our case C:\jboss-4.2.3.GA\
+
# Make sure JBOSS_HOME and JAVA_HOME are set. In our case: C:\jboss-4.2.3.GA\bin and D:\jdk1.6.0 respectively  
 
+
# Create a batch file install.bat in %JBOSS_HOME%/bin directory. Its contents should be as follows:  
4. Make sure JBOSS_HOME and JAVA_HOME are set. In our case: C:\jboss-4.2.3.GA\bin and D:\jdk1.6.0 respectively  
 
 
 
5. Create a batch file install.bat in %JBOSS_HOME%/bin directory. Its contents should be as follows:  
 
  
 
<source lang="bash">
 
<source lang="bash">
Line 116: Line 110:
  
 
set JAVA_HOME=d:/jdk1.6.0
 
set JAVA_HOME=d:/jdk1.6.0
 
 
set javadll=%JAVA_HOME%\jre\bin\client\jvm.dll
 
set javadll=%JAVA_HOME%\jre\bin\client\jvm.dll
 
 
set javatool=%JAVA_HOME%\lib\tools.jar
 
set javatool=%JAVA_HOME%\lib\tools.jar
 
 
set javarun=%JBOSS_HOME%\bin\run.jar
 
set javarun=%JBOSS_HOME%\bin\run.jar
 
 
set outlog=%JBOSS_HOME%\bin\stdout.log
 
set outlog=%JBOSS_HOME%\bin\stdout.log
 
 
set errlog=%JBOSS_HOME%\bin\stderr.log
 
set errlog=%JBOSS_HOME%\bin\stderr.log
 
  
 
JBossService.exe -install JBoss "%javadll%" -Djava.class.path="%javatool%";"%javarun%" -Xms1024M -Xmx1024M -XX:PermSize=64m -XX:MaxPermSize=128m -start org.jboss.Main -stop org.jboss.Main -method systemExit -out "%outlog%" -err "%errlog%" -current "%JBOSS_HOME%\bin" -manual
 
JBossService.exe -install JBoss "%javadll%" -Djava.class.path="%javatool%";"%javarun%" -Xms1024M -Xmx1024M -XX:PermSize=64m -XX:MaxPermSize=128m -start org.jboss.Main -stop org.jboss.Main -method systemExit -out "%outlog%" -err "%errlog%" -current "%JBOSS_HOME%\bin" -manual
Line 148: Line 136:
 
  javaservice -uninstall jboss
 
  javaservice -uninstall jboss
  
 
+
=== Third method ===
enjoy!
+
Start a cmd window,To start the service type:
 
 
== third method ==
 
start a cmd window,To start the service type:
 
  
 
  set JAVA_HOME=d:/jdk1.6.0
 
  set JAVA_HOME=d:/jdk1.6.0
 
 
  set JBOSS_HOME=C:/jboss-4.2.3.GA/
 
  set JBOSS_HOME=C:/jboss-4.2.3.GA/
 
 
  installJboss MSSQLSERVER -auto
 
  installJboss MSSQLSERVER -auto
  
 
MSSQLSERVER is a service that must be running before JBoss starts.
 
MSSQLSERVER is a service that must be running before JBoss starts.
  
 
+
=== Fourth method ===
== fourth method ==
 
 
Is using Microsoft Resource KIT, you can get more information here:
 
Is using Microsoft Resource KIT, you can get more information here:
  
http://support.microsoft.com/kb/137890
+
* http://support.microsoft.com/kb/137890
 +
* http://www.microsoft.com/downloads/details.aspx?FamilyID=F4A453E2-FCEF-49C2-87AC-CEBE233A5F8D&amp;displaylang=en&displaylang=en
  
http://www.microsoft.com/downloads/details.aspx?FamilyID=F4A453E2-FCEF-49C2-87AC-CEBE233A5F8D&amp;displaylang=en&displaylang=en
+
Microsoft resource kit are several programs that covers specific functionalities, not present by default in Windows OS (really it could be a good question why it don't comes by default - other Microsoft policy? the question is that in these utilities are present service registration utility).
  
Microsoft resource kit are several programs that covers specific functionalities, not present by default in Windows OS ( really it could be a good question why it don't comes by default - other Microsoft policy ? the question is that in these utilities are present service registration utility ).
+
[[Category: Installation Guide]]
 +
[[Category:OKM Network]]

Revision as of 10:24, 19 March 2010

These instructions are related to install and run JBoss 4.2.3 as a service, which means that will be launched at system boot and will closed properly on system shutdown.

Running as a Linux Service

For security reasons you shouldn't run JBoss as root. It is better to create an user named openkm and run JBoss from him:

$ adduser openkm

Create a file with the script:

$ vim /etc/init.d/jboss
#!/bin/sh
# /etc/init.d/jboss: Start and stop JBoss AS
ECHO=/bin/echo
TEST=/usr/bin/test
JBOSS_START_SCRIPT=/home/openkm/jboss-4.2.2.GA/bin/run.sh
JBOSS_STOP_SCRIPT=/home/openkm/jboss-4.2.2.GA/bin/shutdown.sh

$TEST -x $JBOSS_START_SCRIPT || exit 0
$TEST -x $JBOSS_STOP_SCRIPT || exit 0

start() {
    $ECHO -n "Starting JBoss"
    su - openkm -c "$JBOSS_START_SCRIPT -b 0.0.0.0 > /dev/null 2> /dev/null &"
    $ECHO "."
}

stop() {
    $ECHO -n "Stopping JBoss"
    su - openkm -c "$JBOSS_STOP_SCRIPT -S > /dev/null &"
    $ECHO "."
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        sleep 30
        start
        ;;
    *)
        $ECHO "Usage: jboss {start|stop|restart}"
        exit 1
esac
exit 0

And make it executable:

$ chmod 755 /etc/init.d/jboss

Now update the run-levels:

$ update-rc.d jboss defaults

Also is a good idea to configure JBoss memory utilization. Edit the file $JBOSS_HOME/bin/run.sh and add a new parameter JAVA_OPTS where you can increase the system memory managed by the JVM (Java Virtual Machine):

DIRNAME=`dirname $0`
PROGNAME=`basename $0`
GREP="grep"
JAVA_OPTS="-Xmx1744m -XX:MaxPermSize=256m"

This example is for a system with 2 GB of RAM.

For more info, read http://jboss.org/community/docs/DOC-11566.

Running as a Windows Service

You can install JBoss as a service in Windows platform by several ways:

First method

JBoss recomended is using jboss native windows take a look here http://community.jboss.org/wiki/RunJBossAsAServiceOnWIndows.

Must be downloaded jboss native in concordance with your architecture 32 bits or 64 bits http://labs.jboss.com/jbossweb/downloads/jboss-native.html.

Uncompress files into your %JBOSS_HOME%

If you want you can edit the service name editing the file %JBOSS_HOME%\bin\service.bat

set SVCNAME=JBAS50SVC
set SVCDISP=JBoss Application Server 5.0
set SVCDESC=JBoss Application Server 5.0.0 GA/Platform: Windows x86

Then you must go to your windows console into %JBOSS_HOME%\bin\ folder and execute

service.bat install

Now in your service control panel there's installed JBoss as a service. We tested it on several Windows and runs well.


Nota clasica.png Other windows service installation methods explained below we've not been tested directly by us.

Second method

  1. Download JavaService-2.0.10.zip from http://download.forge.objectweb.org/javaservice/
  2. Extract to C:\JavaService-2.0.10
  3. copy InstallJBoss.bat,UninstallJBoss.bat, JavaService.exe and JBossService.exe to jboss bin directory. In our case C:\jboss-4.2.3.GA\
  4. Make sure JBOSS_HOME and JAVA_HOME are set. In our case: C:\jboss-4.2.3.GA\bin and D:\jdk1.6.0 respectively
  5. Create a batch file install.bat in %JBOSS_HOME%/bin directory. Its contents should be as follows:
Rem Start Here

set JAVA_HOME=d:/jdk1.6.0
set javadll=%JAVA_HOME%\jre\bin\client\jvm.dll
set javatool=%JAVA_HOME%\lib\tools.jar
set javarun=%JBOSS_HOME%\bin\run.jar
set outlog=%JBOSS_HOME%\bin\stdout.log
set errlog=%JBOSS_HOME%\bin\stderr.log

JBossService.exe -install JBoss "%javadll%" -Djava.class.path="%javatool%";"%javarun%" -Xms1024M -Xmx1024M -XX:PermSize=64m -XX:MaxPermSize=128m -start org.jboss.Main -stop org.jboss.Main -method systemExit -out "%outlog%" -err "%errlog%" -current "%JBOSS_HOME%\bin" -manual

Rem End Here

Make sure to set word wrap off in the file and do not forget the quotes. This will allow the Program Files path to work correctly. You can change the location of stderr.log and stdout.log to other path if you prefer. Start a cmd window and cd to %JBOSS_HOME%\bin. run install.bat by typing install. This will install JBoss as a service. To start the service type:

net start JBoss.


JBoss should now be running as a service.

uninstall jboss service:

javaservice -uninstall jboss

Third method

Start a cmd window,To start the service type:

set JAVA_HOME=d:/jdk1.6.0
set JBOSS_HOME=C:/jboss-4.2.3.GA/
installJboss MSSQLSERVER -auto

MSSQLSERVER is a service that must be running before JBoss starts.

Fourth method

Is using Microsoft Resource KIT, you can get more information here:

Microsoft resource kit are several programs that covers specific functionalities, not present by default in Windows OS (really it could be a good question why it don't comes by default - other Microsoft policy? the question is that in these utilities are present service registration utility).