I am having trouble running JBoss as a service / daemon on Fedora 8...
Have installed JBoss 5.1.0 GA under the root user and didn't create a
jboss user.
Here's what I did so far:
(1) Created the following jboss script in /etc/init.d/:
#!/bin/sh
# chkconfig: 3 87 20
#make sure java is in your path
JAVAPTH=${JAVAPTH:-"/usr/java/jdk/bin/java"}
echo JAVAPTH $JAVAPTH
# Set JAVA_HOME
JAVA_HOME=${JAVA_HOME:-"/usr/java/jdk"}
echo JAVA_HOME $JAVA_HOME
echo JAVA $JAVA
# Set classpath
CLASSPATH=$CLASSPATH:$JBOSS_HOME/bin/run.jar:$JAVA_HOME/lib/tools.jar;
echo CLASSPATH $CLASSPATH
#define where jboss is - this is the directory containing directories
log, bin, conf etc
JBOSS_HOME=${JBOSS_HOME:-"/usr/jboss-5.1.0.GA"}
#define the user under which jboss will run, or use 'RUNASIS' to run
as the current user
JBOSS_USER=${JBOSS_USER:-"RUNASIS"}
#configuration to use, usually one of 'minimal', 'default', 'all'
JBOSS_CONF=${JBOSS_CONF:-"default"}
#the host where jboss should answer. o.o.o.o means answer all calls.
set this to
yourhost.com
JBOSS_HOST=${JBOSS_HOST:-"0.0.0.0"}
start(){
echo "Starting jboss.."
# If using an SELinux system such as RHEL 4, use the command below
# instead of the "su":
# eval "runuser - jboss -c '/opt/jboss/current/bin/run.sh > /dev/null
2> /dev/null &'
# if the 'su -l ...' command fails (the -l flag is not recognized by
my su cmd) try:
# sudo -u jboss /opt/jboss/bin/run.sh > /dev/null 2> /dev/null &
#su -l jboss -c '/current/bin/run.sh > /dev/null 2> /dev/null &'
# eval "runuser - jboss -c '${JBOSS_HOME}/bin/run.sh > /dev/null 2> /
dev/null &'"
sh ${JBOSS_HOME}/bin/run.sh
}
stop(){
echo "Stopping jboss.."
# If using an SELinux system such as RHEL 4, use the command below
# instead of the "su":
# eval "runuser - jboss -c '/opt/jboss/current/bin/shutdown.sh -S &'
# if the 'su -l ...' command fails try:
# sudo -u jboss /opt/jboss/bin/shutdown.sh -S &
# su -l jboss -c '/opt/jboss/current/bin/shutdown.sh -S &'
sh ${JBOSS_HOME}/bin/shutdown.sh
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: jboss {start|stop}"
exit 1
esac
exit 0
(2) Set up permissions and symbolic links (for run levels):
sudo chown root:root /etc/init.d/jboss
sudo chmod ug+x /etc/init.d/jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc3.d/S84jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc4.d/S84jboss
ln -s /etc/rc.d/init.d/jboss /etc/rc5.d/S84jboss
ln -s /etc/rc.d/init.d/jboss/etc/rc6.d/K15jboss
ln -s /etc/rc.d/init.d/jboss/etc/rc0.d/K15jboss
ln -s /etc/rc.d/init.d/jboss/etc/rc1.d/K15jboss
ln -s /etc/rc.d/init.d/jboss/etc/rc2.d/K15jboss
(3) When I run it like this:
/etc/init.d/./jboss
It runs perfectly (please take note the echo statements that show up
first):
JAVAPTH /usr/java/jdk/bin/java
JAVA_HOME /usr/java/jdk
JAVA
CLASSPATH .:/usr/jboss-5.1.0.GA/bin/run.jar:/usr/java/jdk/lib/tools.jar:
/usr/jboss-5.1.0.GA/bin/run.jar:/usr/java/jdk/lib/tools.jar
Starting jboss..
=
========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /usr/jboss-5.1.0.GA
JAVA: /usr/java/jdk/bin/java
JAVA_OPTS: -Dprogram.name=run.sh -server -Xms128m -Xmx512m -
XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -
Dsun.rmi.dgc.client.gcInterval=3600000 -
Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.bind.address=0.0.0.0 -
Xdebug-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -
Djava.net.preferIPv4Stack=true
CLASSPATH: /usr/jboss-5.1.0.GA/bin/run.jar:/usr/java/jdk/lib/
tools.jar
=
========================================================================
22:50:15,825 INFO [ServerImpl] Starting JBoss (Microcontainer)...
...
22:53:29,933 INFO [ClasspathResourceConfig] Provider classes found:
22:53:33,927 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on
http-0.0.0.0-8080
22:53:33,950 INFO [AjpProtocol] Starting Coyote AJP/1.3 on
ajp-0.0.0.0-8009
22:53:34,021 INFO [ServerImpl] JBoss (Microcontainer) [5.1.0.GA
(build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 3m:18s:
169ms
Notice the JAVA and CLASSPATH are set...
But when I try to do this:
service jboss start
It breaks (and the JAVA and the CLASSPATH are not set with JAVA):
JAVAPTH /usr/java/jdk/bin/java
JAVA_HOME /usr/java/jdk
JAVA
CLASSPATH :/bin/run.jar:/usr/java/jdk/lib/tools.jar
Starting jboss..
=
========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /usr/jboss-5.1.0.GA
JAVA: java
JAVA_OPTS: -Dprogram.name=run.sh -Xms128m -Xmx512m -
XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -
Dsun.rmi.dgc.client.gcInterval=3600000 -
Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.bind.address=0.0.0.0 -
Xdebug-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -
Djava.net.preferIPv4Stack=true
CLASSPATH: /usr/jboss-5.1.0.GA/bin/run.jar
=
========================================================================
/usr/jboss-5.1.0.GA/bin/run.sh: line 261: java: command not found
(4) This code block here (line 261 in $JBOSS_HOME/bin/run.sh):
Code:
while true; do
if [ "x$LAUNCH_JBOSS_IN_BACKGROUND" = "x" ]; then
# Execute the JVM in the foreground
"$JAVA" $JAVA_OPTS \
-Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
-classpath "$JBOSS_CLASSPATH" \
org.jboss.Main "$@"
JBOSS_STATUS=$?
(5) Fortunately, I was able to issue these with chkconfig:
chkconfig --add jboss
chkconfig jboss on
(6) Created .bash_profile under root:
Code:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
if [ -f /root/firstlogin ] ; then
echo " --[ see /etc/ec2/release-notes ]--" && echo
rm -f /root/firstlogin
fi
# User specific environment and startup programs
export JAVA_HOME="/usr/java/jdk";
export JBOSS_HOME="/usr/jboss-5.1.0.GA";
export CLASSPATH=.:$JBOSS_HOME/bin/run.jar:$JAVA_HOME/lib/tools.jar;
PATH=$PATH:$JAVA_HOME/bin:$HOME/bin
export PATH
unset USERNAME
It seems that the environment is completely different (because java
unsets) when I run service jboss start opposed to doing it manually: /
etc/init.d/./jboss.
Does anyone know what I am possibly missing or doing wrong?
Would be very appreciative if someone could help...