Difference between revisions of "Configure JBoss service"

From OpenKM Documentation
Jump to: navigation, search
m
 
(69 intermediate revisions by 6 users not shown)
Line 1: Line 1:
For security reasons you shouldn't run JBoss as '''root'''. It is better to create an user named openkm and run JBoss from him:
+
{{TOCright}} __TOC__
  
  $ adduser openkm
+
These instructions are related to installing and running JBoss 4.2.3 as a service, which means that will be launched at system boot and will be 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 a user named openkm and run JBoss from him:
 +
 
 +
  $ sudo adduser openkm
 +
 
 +
It's important to check if owner of OpenKM dir is openkm user, if not you can use chown:
 +
 
 +
$ sudo chown -R openkm /home/openkm
  
 
Create a file with the script:
 
Create a file with the script:
  
  $ vim /etc/init.d/jboss
+
  $ sudo vim /etc/init.d/jboss
  
 
<source lang="bash">
 
<source lang="bash">
 
#!/bin/sh
 
#!/bin/sh
# /etc/init.d/jboss: Start and stop JBoss AS
+
 
 +
### BEGIN INIT INFO
 +
# Provides:          jboss
 +
# Required-Start:    $remote_fs $syslog
 +
# Required-Stop:    $remote_fs $syslog
 +
# Default-Start:    2 3 4 5
 +
# Default-Stop:      0 1 6
 +
# Short-Description: Start and stop JBoss AS
 +
# Description:      Enable JBoss AS service provided by daemon.
 +
### END INIT INFO
 +
 
ECHO=/bin/echo
 
ECHO=/bin/echo
 
TEST=/usr/bin/test
 
TEST=/usr/bin/test
JBOSS_START_SCRIPT=/home/openkm/jboss-4.2.2.GA/bin/run.sh
+
JBOSS_USER=openkm
JBOSS_STOP_SCRIPT=/home/openkm/jboss-4.2.2.GA/bin/shutdown.sh
+
JBOSS_IP=127.0.0.1
 
+
JBOSS_HOME=/home/openkm/jboss-4.2.3.GA
 +
JBOSS_START_SCRIPT=$JBOSS_HOME/bin/run.sh
 +
JBOSS_STOP_SCRIPT=$JBOSS_HOME/bin/shutdown.sh
 +
 
$TEST -x $JBOSS_START_SCRIPT || exit 0
 
$TEST -x $JBOSS_START_SCRIPT || exit 0
 
$TEST -x $JBOSS_STOP_SCRIPT || exit 0
 
$TEST -x $JBOSS_STOP_SCRIPT || exit 0
 
+
 
start() {
 
start() {
 
     $ECHO -n "Starting JBoss"
 
     $ECHO -n "Starting JBoss"
     su - openkm -c "$JBOSS_START_SCRIPT -b 0.0.0.0 > /dev/null 2> /dev/null &"
+
     su - $JBOSS_USER -c "$JBOSS_START_SCRIPT -b $JBOSS_IP > /dev/null &"
 
     $ECHO "."
 
     $ECHO "."
 
}
 
}
 
+
 
stop() {
 
stop() {
 
     $ECHO -n "Stopping JBoss"
 
     $ECHO -n "Stopping JBoss"
     su - openkm -c "$JBOSS_STOP_SCRIPT -S > /dev/null &"
+
     su - $JBOSS_USER -c "$JBOSS_STOP_SCRIPT -s $JBOSS_IP > /dev/null &"
 +
    while [ "$(ps -fu $JBOSS_USER | grep java | grep jboss | wc -l)" -gt "0" ]; do
 +
        sleep 5; $ECHO -n "."
 +
    done
 
     $ECHO "."
 
     $ECHO "."
 
}
 
}
 
+
 
case "$1" in
 
case "$1" in
 
     start)
 
     start)
Line 51: Line 76:
 
And make it executable:
 
And make it executable:
  
  $ chmod 755 /etc/init.d/jboss
+
  $ sudo chmod 755 /etc/init.d/jboss
  
 
Now update the run-levels:
 
Now update the run-levels:
  
  $ update-rc.d jboss defaults
+
  $ sudo update-rc.d jboss defaults
 +
  Adding system startup for /etc/init.d/jboss ...
 +
    /etc/rc0.d/K20jboss -> ../init.d/jboss
 +
    /etc/rc1.d/K20jboss -> ../init.d/jboss
 +
    /etc/rc6.d/K20jboss -> ../init.d/jboss
 +
    /etc/rc2.d/S20jboss -> ../init.d/jboss
 +
    /etc/rc3.d/S20jboss -> ../init.d/jboss
 +
    /etc/rc4.d/S20jboss -> ../init.d/jboss
 +
    /etc/rc5.d/S20jboss -> ../init.d/jboss
 +
 
 +
start jboss service:
 +
 
 +
$ sudo service jboss start
 +
 
 +
stop jboss service:
  
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):
+
$ sudo service jboss stop
 +
 
 +
{{Note|If you are a Red Hat user use:
 +
  $ chkconfig --add jboss
 +
Take a look at [http://www.cyberciti.biz/faq/rhel5-update-rcd-command/ update-rc.d like command on Redhat Enterprise / CentOS Linux].}}
 +
 
 +
It's also 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):
  
 
<source lang="bash" highlight="4">
 
<source lang="bash" highlight="4">
Line 70: Line 115:
 
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]]
+
== Configure on Redhat / CentOS ==
[[Category:OKM Network]]
+
Copy the jboss_init_redhat.sh located into $JBOSS_HOME/bin to /etc/init.d/jboss
 +
$ cp bin/jboss_init_redhat.sh /etc/init.d/jboss
 +
 
 +
Make jboss script executable
 +
$ chmod +x /etc/init.d/jboss
 +
 
 +
Modify default jboss script ( add or modify some lines )
 +
'''# chkconfig: - 64 36'''
 +
'''# description: Jboss Start|Restart|Stop Application Server'''
 +
'''# pidfile: /var/run/jboss.pid'''
 +
 +
.... 
 +
 +
JBOSS_HOME=${JBOSS_HOME:-"'''/home/openkm/jboss-4.2.3.GA'''"}
 +
   
 +
#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
 +
JBOSS_USER=${JBOSS_USER:-"'''openkm'''"}
 +
 
 +
#make sure java is in your path
 +
JAVAPTH=${JAVAPTH:-"'''/usr/java/jdk1.6.0_27/bin'''"}
 +
 
 +
#configuration to use, usually one of 'minimal', 'default', 'all'
 +
JBOSS_CONF=${JBOSS_CONF:-"'''default'''"}
 +
 
 +
#if JBOSS_HOST specified, use -b to bind jboss services to that address
 +
'''JBOSS_HOST="0.0.0.0"'''
 +
JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}
 +
 
 +
Add jboss script as service
 +
$ chkconfig --add jboss
 +
 
 +
If you see an error message like '''service jboss does not support chkconfig''', edit /etc/init.d/jboss file and add the following lines right after "#!/bin/sh":
  
----
+
# chkconfig: 345 90 10
 +
# description: Runs the JBoss Application Server
 +
# processname: jboss
  
== Running JBoss 4.2.3 as a Windows Service ==
+
Change service level
 +
$ chkconfig jboss --level 3 on
  
Jboss recomended is using jboss '''native windows take''' a look here http://community.jboss.org/wiki/RunJBossAsAServiceOnWIndows
+
Run or stop jboss service
 +
$ service jboss start
 +
$ service jboss stop
  
Must be downloaded '''jboss native''' in concordance with your architecture 32 bits or 64 bits http://labs.jboss.com/jbossweb/downloads/jboss-native.html
+
== Running as a Windows Service ==
 +
You can install JBoss as a service on the Windows platform in several ways:
  
Un compresss files into your %JBOSS_HOME%
+
=== First method ===
 +
JBoss recomended is using jboss '''native windows'''. Take a look here http://community.jboss.org/wiki/RunJBossAsAServiceOnWIndows and http://community.jboss.org/wiki/JBossNativeWindows. Download '''jboss native''' in concordance with your architecture - 32 bit or 64 bit. http://labs.jboss.com/jbossweb/downloads/ ( jboss native ).
  
If you want you can edit the service name editing the file %JBOSS_HOME%\bin\service.bat
+
* Uncompress files into your %JBOSS_HOME%
 +
* If you want, you can edit the service name by editing the file %JBOSS_HOME%\bin\service.bat
  
set SVCNAME=JBAS50SVC
+
<source lang="dos">
set SVCDISP=JBoss Application Server 5.0
+
set SVCNAME=JBAS50SVC
set SVCDESC=JBoss Application Server 5.0.0 GA/Platform: Windows x86
+
set SVCDISP=JBoss Application Server 5.0
 +
set SVCDESC=JBoss Application Server 5.0.0 GA/Platform: Windows x86
 +
</source>
  
Then you must go to your windows console into %JBOSS_HOME%\bin\ folder and execute
+
* Then open a command promt window, cd to the %JBOSS_HOME%\bin\ folder and execute
 
   
 
   
 
  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, JBoss is installed as a service. We tested it on several Windows versions and it runs well.
  
'''Other windows service installation methods explained belowe we've not been tested directly by us.'''  
+
{{Warning|If you're executing '''service.bat''' on '''Windows Vista / Windows 7''' you may get an '''Access Denied error'''. The command prompt works slightly differently in Vista. By default when you run cmd.exe, it does not give administrator rights. To get around it, create a shortcut to cmd.exe on the desktop, open Properties, Compatibility tab and check the box for Administrator rights. Or simply execute the shortcut as administrator ( popup menu with right click ). Then you can execute '''service.bat install'''.}}
  
 +
{{Note|Other windows service installation methods explained below haven't been tested directly by us.}}
  
== second method ==
+
=== Second method ===
 +
* Download JavaService-2.0.10.zip from http://download.forge.objectweb.org/javaservice/
 +
* Extract to C:\JavaService-2.0.10
 +
* copy InstallJBoss.bat,UninstallJBoss.bat, JavaService.exe (JavaService.exe must be renames as 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 and D:\jdk1.6.0 respectively
 +
* Create a batch file install.bat in %JBOSS_HOME%/bin directory. Its contents should be as follows:
 +
 
 +
<source lang="dos">
 +
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
  
1. Download JavaService-2.0.10.zip from http://download.forge.objectweb.org/javaservice/
+
JBossService.exe -install JBoss "%javadll%" -Djava.class.path="%javatool%";"%javarun%" -Xms1024M -Xmx1024M -XX:PermSize=64m -XX:MaxPermSize=128m -start org.jboss.Main -params -b 0.0.0.0 -stop org.jboss.Main -method systemExit -out "%outlog%" -err "%errlog%" -current "%JBOSS_HOME%\bin" -manual
  
2. Extract to C:\JavaService-2.0.10
+
Rem End Here
 +
</source>
  
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 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 another path if you prefer.  
 +
*Start a command prompt 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:
  
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
+
net start JBoss.
  
5. Create a batch file install.bat in %JBOSS_HOME%/bin directory. Its contents should be as follows:  
+
*JBoss should now be running as a service.
 +
* To uninstall the JBoss service:
  
<source lang="bash">
+
javaservice -uninstall jboss
Rem Start Here
+
 
 +
=== Third method ===
 +
Start a command prompt window. To start the service, type:
  
 +
<source lang="dos">
 
set JAVA_HOME=d:/jdk1.6.0
 
set JAVA_HOME=d:/jdk1.6.0
 +
set JBOSS_HOME=C:/jboss-4.2.3.GA/
 +
installJboss MSSQLSERVER -auto
 +
</source>
 +
 +
MSSQLSERVER is a service that must be running before JBoss starts.
  
set javadll=%JAVA_HOME%\jre\bin\client\jvm.dll
+
=== Fourth method ===
 +
Is using Microsoft Resource KIT, you can get more information here:
 +
 
 +
* http://support.microsoft.com/kb/137890
 +
* [http://www.microsoft.com/downloads/details.aspx?FamilyID=F4A453E2-FCEF-49C2-87AC-CEBE233A5F8D&amp;displaylang=en&displaylang=en|Microsoft Windows XP Embedded SP2 Resource Kit]
  
set javatool=%JAVA_HOME%\lib\tools.jar
+
Microsoft resource kit are several programs that cover specific functionalities not present by default in Windows OS (really it could be a good question why it doesn't come by default - other Microsoft policy? The thing is that in these utilities is present a service registration utility).
  
set javarun=%JBOSS_HOME%\bin\run.jar
+
== Mac OS X Server ==
 +
Create a file called jboss.plist with values ( some paths, adminserver user name could be different ) save into /Users/adminuser/Library/LaunchAgents
  
set outlog=%JBOSS_HOME%\bin\stdout.log
+
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
 +
                      "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 +
<plist version="1.0">
 +
  <dict>
 +
    <key>Label</key>
 +
    <string>openkm</string>
  
set errlog=%JBOSS_HOME%\bin\stderr.log
+
    <key>UserName</key>
 +
    <string>adminuser</string>
  
 +
    <key>GroupName</key>
 +
    <string>staff</string>
  
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
+
    <key>ProgramArguments</key>
 +
    <array>
 +
      <string>/Users/adminserver/jboss-4.2.3.GA/bin/run.sh</string>
 +
      <string>-c</string>
 +
      <string>default</string>
 +
      <string>-b</string>
 +
      <string>0.0.0.0</string>
 +
    </array>
  
Rem End Here
+
    <key>RunAtLoad</key>
 +
    <true/>
 +
  </dict>
 +
</plist>
 
</source>
 
</source>
  
Make sure to set word wrap off in the file and do not forget the quotes. This will allow the Program
+
Change the user owner to root and privilegees to 644
Files path to work correctly. You can change the location of stderr.log and stdout.log to other path
+
$ sudo chown root jboss.plist
if you prefer.  
+
$ sudo chmod 644 jboss.plist
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:
+
Register as service
 +
$ launchctl load <path-to-file>/jboss.plist
 +
 
 +
Start service
 +
$ launchctl start openkm
 +
 
 +
Stop service
 +
$ launchctl stop openkm
 +
 
 +
More information at [http://community.jboss.org/wiki/RunningJBossAsAMacOSXService Running JBoss As A Mac OS X Service].
 +
 
 +
== FreeBSD 9.0 ==
 +
FreeBSD service configuration is a forum contribution, more information at http://forum.openkm.com/viewtopic.php?f=3&t=5766&p=17109#p17109
 +
 
 +
Create file /usr/local/etc/rc.d/openkm.sh
 +
 
 +
<source lang="bash">
 +
#!/bin/sh
 +
# Openkm startup Script
 +
 
 +
# PROVIDE: Openkm
 +
# REQUIRE: mysql LOGIN
 +
# KEYWORD: shutdown
 +
 
 +
. /etc/rc.subr
 +
 
 +
name="Openkm"
 +
rcvar=${name}_enable
 +
Openkm_enable=${Openkm_enable-"NO"}
 +
 
 +
start_cmd="${name}_start"
 +
stop_cmd="${name}_stop"
 +
 
 +
load_rc_config $name
 +
 
 +
JAVA_HOME="/usr/local/openjdk6/";
 +
 
 +
export JAVA_HOME
 +
 
 +
procname="java"
 +
 
 +
Openkm_start(){
 +
echo "Starting OpenKM....."
 +
rm -r /alldata/programs/jboss/server/default/work &
 +
rm -r /alldata/programs/jboss/server/default/tmp &
 +
/usr/local/lib/libreoffice/program/soffice "--accept=socket,host=localhost,port=2222;urp;StarOffice.ServiceManager" --nologo --headless --nofirststartwizard &
 +
su -m nobody -c /alldata/programs/jboss/bin/run.sh -b 0.0.0.0 & > /dev/null
  
net start JBoss.
+
}
  
 +
Openkm_stop(){
  
JBoss should now be running as a service.  
+
echo "Stopping OpenKM....."
 +
/alldata/programs/jboss/bin/shutdown.sh -S
 +
killall -9 soffice.bin &
 +
}
  
uninstall jboss service:
 
  
javaservice -uninstall jboss
+
run_rc_command "$1"
 +
</source>
  
 +
Add the following to /etc/rc.conf
 +
openkm_enable="YES"
  
enjoy!
+
Add the following to /etc/rc.conf
 +
soffice_enable="YES"
  
== third method ==
+
== JBoss with SSL ==
start a cmd window,To start the service type:
+
We encourage using apache proxy to port 80 or 443 and not expose directly jboss ports. There could be some security bugs if the jboss ports are exposed. For those people who decide to expose jboss ports, there's a problem with IE and https / SSL jboss configuration. To solve it:
  
set JAVA_HOME=d:/jdk1.6.0
+
Edit the file $JBOSS_HOME/server/default/deploy/jboss-web.deployer/server.xml and uncomment
  
set JBOSS_HOME=C:/jboss-4.2.3.GA/
+
<source lang="xml">
 +
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
 +
              maxThreads="150" scheme="https" secure="true"
 +
                keystorePass="XxXxXxXx"
 +
              clientAuth="false" sslProtocol="TLS" />
 +
</source>
  
installJboss MSSQLSERVER -auto
+
You need to generate some keystorePass.
  
MSSQLSERVER is a service that must be running before JBoss starts.
+
[[Category: Installation Guide]]

Latest revision as of 17:21, 1 October 2012

These instructions are related to installing and running JBoss 4.2.3 as a service, which means that will be launched at system boot and will be 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 a user named openkm and run JBoss from him:

$ sudo adduser openkm

It's important to check if owner of OpenKM dir is openkm user, if not you can use chown:

$ sudo chown -R openkm /home/openkm

Create a file with the script:

$ sudo vim /etc/init.d/jboss
#!/bin/sh

### BEGIN INIT INFO
# Provides:          jboss
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and stop JBoss AS
# Description:       Enable JBoss AS service provided by daemon.
### END INIT INFO
 
ECHO=/bin/echo
TEST=/usr/bin/test
JBOSS_USER=openkm
JBOSS_IP=127.0.0.1
JBOSS_HOME=/home/openkm/jboss-4.2.3.GA
JBOSS_START_SCRIPT=$JBOSS_HOME/bin/run.sh
JBOSS_STOP_SCRIPT=$JBOSS_HOME/bin/shutdown.sh
 
$TEST -x $JBOSS_START_SCRIPT || exit 0
$TEST -x $JBOSS_STOP_SCRIPT || exit 0
 
start() {
    $ECHO -n "Starting JBoss"
    su - $JBOSS_USER -c "$JBOSS_START_SCRIPT -b $JBOSS_IP > /dev/null &"
    $ECHO "."
}
 
stop() {
    $ECHO -n "Stopping JBoss"
    su - $JBOSS_USER -c "$JBOSS_STOP_SCRIPT -s $JBOSS_IP > /dev/null &"
    while [ "$(ps -fu $JBOSS_USER | grep java | grep jboss | wc -l)" -gt "0" ]; do
        sleep 5; $ECHO -n "."
    done
    $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:

$ sudo chmod 755 /etc/init.d/jboss

Now update the run-levels:

$ sudo update-rc.d jboss defaults
 Adding system startup for /etc/init.d/jboss ...
   /etc/rc0.d/K20jboss -> ../init.d/jboss
   /etc/rc1.d/K20jboss -> ../init.d/jboss
   /etc/rc6.d/K20jboss -> ../init.d/jboss
   /etc/rc2.d/S20jboss -> ../init.d/jboss
   /etc/rc3.d/S20jboss -> ../init.d/jboss
   /etc/rc4.d/S20jboss -> ../init.d/jboss
   /etc/rc5.d/S20jboss -> ../init.d/jboss

start jboss service:

$ sudo service jboss start

stop jboss service:

$ sudo service jboss stop

Nota clasica.png If you are a Red Hat user use:
 $ chkconfig --add jboss
Take a look at update-rc.d like command on Redhat Enterprise / CentOS Linux.

It's also 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.

Configure on Redhat / CentOS

Copy the jboss_init_redhat.sh located into $JBOSS_HOME/bin to /etc/init.d/jboss

$ cp bin/jboss_init_redhat.sh /etc/init.d/jboss 

Make jboss script executable

$ chmod +x /etc/init.d/jboss 

Modify default jboss script ( add or modify some lines )

# chkconfig: - 64 36
# description: Jboss Start|Restart|Stop Application Server
# pidfile: /var/run/jboss.pid

....   

JBOSS_HOME=${JBOSS_HOME:-"/home/openkm/jboss-4.2.3.GA"}
   
#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
JBOSS_USER=${JBOSS_USER:-"openkm"}
  
#make sure java is in your path
JAVAPTH=${JAVAPTH:-"/usr/java/jdk1.6.0_27/bin"}
  
#configuration to use, usually one of 'minimal', 'default', 'all'
JBOSS_CONF=${JBOSS_CONF:-"default"}
  
#if JBOSS_HOST specified, use -b to bind jboss services to that address
JBOSS_HOST="0.0.0.0"
JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}

Add jboss script as service

$ chkconfig --add jboss

If you see an error message like service jboss does not support chkconfig, edit /etc/init.d/jboss file and add the following lines right after "#!/bin/sh":

# chkconfig: 345 90 10
# description: Runs the JBoss Application Server
# processname: jboss 

Change service level

$ chkconfig jboss --level 3 on

Run or stop jboss service

$ service jboss start
$ service jboss stop

Running as a Windows Service

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

First method

JBoss recomended is using jboss native windows. Take a look here http://community.jboss.org/wiki/RunJBossAsAServiceOnWIndows and http://community.jboss.org/wiki/JBossNativeWindows. Download jboss native in concordance with your architecture - 32 bit or 64 bit. http://labs.jboss.com/jbossweb/downloads/ ( jboss native ).

  • Uncompress files into your %JBOSS_HOME%
  • If you want, you can edit the service name by 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 open a command promt window, cd to the %JBOSS_HOME%\bin\ folder and execute
service.bat install
  • Now in your service control panel, JBoss is installed as a service. We tested it on several Windows versions and it runs well.

Nota advertencia.png If you're executing service.bat on Windows Vista / Windows 7 you may get an Access Denied error. The command prompt works slightly differently in Vista. By default when you run cmd.exe, it does not give administrator rights. To get around it, create a shortcut to cmd.exe on the desktop, open Properties, Compatibility tab and check the box for Administrator rights. Or simply execute the shortcut as administrator ( popup menu with right click ). Then you can execute service.bat install.


Nota clasica.png Other windows service installation methods explained below haven't been tested directly by us.

Second method

  • Download JavaService-2.0.10.zip from http://download.forge.objectweb.org/javaservice/
  • Extract to C:\JavaService-2.0.10
  • copy InstallJBoss.bat,UninstallJBoss.bat, JavaService.exe (JavaService.exe must be renames as 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 and D:\jdk1.6.0 respectively
  • 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 -params -b 0.0.0.0 -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 another path if you prefer.

  • Start a command prompt 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.
  • To uninstall the JBoss service:
javaservice -uninstall jboss

Third method

Start a command prompt 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 cover specific functionalities not present by default in Windows OS (really it could be a good question why it doesn't come by default - other Microsoft policy? The thing is that in these utilities is present a service registration utility).

Mac OS X Server

Create a file called jboss.plist with values ( some paths, adminserver user name could be different ) save into /Users/adminuser/Library/LaunchAgents

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
                       "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>openkm</string>

    <key>UserName</key>
    <string>adminuser</string>

    <key>GroupName</key>
    <string>staff</string>

    <key>ProgramArguments</key>
    <array>
      <string>/Users/adminserver/jboss-4.2.3.GA/bin/run.sh</string>
      <string>-c</string>
      <string>default</string>
      <string>-b</string>
      <string>0.0.0.0</string>
    </array>

    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

Change the user owner to root and privilegees to 644

$ sudo chown root jboss.plist
$ sudo chmod 644 jboss.plist

Register as service

$ launchctl load <path-to-file>/jboss.plist

Start service

$ launchctl start openkm

Stop service

$ launchctl stop openkm

More information at Running JBoss As A Mac OS X Service.

FreeBSD 9.0

FreeBSD service configuration is a forum contribution, more information at http://forum.openkm.com/viewtopic.php?f=3&t=5766&p=17109#p17109

Create file /usr/local/etc/rc.d/openkm.sh

#!/bin/sh
# Openkm startup Script

# PROVIDE: Openkm
# REQUIRE: mysql LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="Openkm"
rcvar=${name}_enable
Openkm_enable=${Openkm_enable-"NO"}

start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name

JAVA_HOME="/usr/local/openjdk6/";

export JAVA_HOME

procname="java"

Openkm_start(){
echo "Starting OpenKM....."
rm -r /alldata/programs/jboss/server/default/work &
rm -r /alldata/programs/jboss/server/default/tmp &
/usr/local/lib/libreoffice/program/soffice "--accept=socket,host=localhost,port=2222;urp;StarOffice.ServiceManager" --nologo --headless --nofirststartwizard &
su -m nobody -c /alldata/programs/jboss/bin/run.sh -b 0.0.0.0 & > /dev/null

}

Openkm_stop(){

echo "Stopping OpenKM....."
/alldata/programs/jboss/bin/shutdown.sh -S
killall -9 soffice.bin &
}


run_rc_command "$1"

Add the following to /etc/rc.conf

openkm_enable="YES"

Add the following to /etc/rc.conf

soffice_enable="YES"

JBoss with SSL

We encourage using apache proxy to port 80 or 443 and not expose directly jboss ports. There could be some security bugs if the jboss ports are exposed. For those people who decide to expose jboss ports, there's a problem with IE and https / SSL jboss configuration. To solve it:

Edit the file $JBOSS_HOME/server/default/deploy/jboss-web.deployer/server.xml and uncomment

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
                keystorePass="XxXxXxXx"
               clientAuth="false" sslProtocol="TLS" />

You need to generate some keystorePass.