Tomcat 7.0.26 failing to start jsvc - java

So I had a tomcat 7.026 smoothly running on a CentOS 6.7 Server on its default port 8080.
Recently it stopped running on its own.
Here are the out put of each:
sudo service easy-tomcat7 start
Failed to start Tomcat
sudo service easy-tomcat7 status
pidof: invalid options on command line!
pidof: invalid options on command line!
jsvc.exec is stopped
ps aux | grep tomcat
root 4293 1.4 2.3 5939868 389996 pts/0 Sl 14:16 0:14
/usr/java/jdk1.7.0_05/bin/java
-Djava.util.logging.config.file=/usr/share/apache-tomcat-7.0.26/conf/logging.properties
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/share/apache-tomcat-7.0.26/endorsed -classpath /usr/share/apache-tomcat-7.0.26/bin/bootstrap.jar:/usr/share/apache-tomcat-7.0.26/bin/tomcat-juli.jar
-Dcatalina.base=/usr/share/apache-tomcat-7.0.26 -Dcatalina.home=/usr/share/apache-tomcat-7.0.26 -Djava.io.tmpdir=/usr/share/apache-tomcat-7.0.26/temp org.apache.catalina.startup.Bootstrap start
root 16821 0.0 0.0 8548 384 ? Ss 14:30 0:00
jsvc.exec -user tomcat -cwd /usr/local/easy/share/easy-tomcat7
-pidfile /var/run/easy-tomcat7.pid -cp /usr/local/easy/bin/bootstrap.jar:/usr/local/easy/bin/tomcat-juli.jar:/usr/local/easy/share/java/commons-daemon.jar
-Djava.endorsed.dirs=/usr/local/easy/share/easy-tomcat7/endorsed -outfile /var/log/easy-tomcat7/catalina.out -errfile /var/log/easy-tomcat7/catalina.err -verbose
org.apache.catalina.startup.Bootstrap start
tomcat 16823 9.4 3.5 6190668 574344 ? Sl 14:30 0:15
jsvc.exec -user tomcat -cwd /usr/local/easy/share/easy-tomcat7
-pidfile /var/run/easy-tomcat7.pid -cp /usr/local/easy/bin/bootstrap.jar:/usr/local/easy/bin/tomcat-juli.jar:/usr/local/easy/share/java/commons-daemon.jar
-Djava.endorsed.dirs=/usr/local/easy/share/easy-tomcat7/endorsed -outfile /var/log/easy-tomcat7/catalina.out -errfile /var/log/easy-tomcat7/catalina.err -verbose
org.apache.catalina.startup.Bootstrap start
Killing those processes aren't helping , as well as service start, restart, force-reload ... etc
Finally here's the script of easy-tomcat7
. /etc/rc.d/init.d/functions
case $1 in
start)
file=/usr/sbin/starttomcat
# no way to start tomcat
if [ ! -x $file ]; then
echo "Missing $file"
ERROR=1
else
# tomcat disabled by whm
if [ -e /etc/tomcatdisable ]; then
echo "Tomcat is disabled by cPanel/WHM"
ERROR=0
else
ERROR=0
status jsvc.exec &>/dev/null
# tomcat already running
if [ $? -eq 0 ]; then
echo "Tomcat already started"
# start tomcat, not running
else
$file &>/dev/null
sleep 1 # just to make sure
status jsvc.exec &>/dev/null
if [ $? -eq 0 ]; then
ERROR=0
else
echo "Failed to start Tomcat"
ERROR=1
fi
fi
fi
fi
;;
stop)
file=/usr/sbin/stoptomcat
if [ ! -x $file ]; then
echo "Missing $file"
ERROR=1
else
$file
ERROR=0
fi
;;
restart)
file=/usr/local/cpanel/scripts/restartsrv_tomcat
if [ ! -x $file ]; then
echo "Missing $file"
ERROR=1
else
$file
fi
;;
status|fullstatus)
status jsvc.exec
;;
*)
echo $"Usage: $0 {start|stop|restart|status|fullstatus}"
ERROR=2 esac
exit $ERROR

I finally resolved the issue.
After running
java -version
It seemed that the Java Installation was somehow corrupted so all I had to do was to uninstall and re-install Java and that made the trick for me.

Related

How to deploy Java war file using Jenkinsfile in jenkins pipeline

In jenkins maven project we can use BUILD_ID=DontKillMe to prevent hudson script shutdown the shell calls.
Like: BUILD_ID=DontKillMe java -jar target.jar
But add BUILD_ID is not work in Jenkinsfile.
Jenkinsfile:
#!/usr/bin/env groovy
node {
stage('Build') {
checkout scm
sh '/opt/gradle/gradle-4.1/bin/gradle clean build'
}
stage('Deploy') {
sh 'mkdir -p /opt/www/foobar'
sh 'cp build/libs/*.war /opt/www/foobar/newest.war'
sh 'chmod 755 ./deploy.sh'
sh 'nohup ./deploy.sh &'
sh 'while ! httping -qc1 http://localhost:10000 ; do sleep 1 ; done'
}
}
After hudson script executed, all the shells called by hudson script would be shutdown. Even double nohup still not work.
deploy.sh:
#!/bin/bash
nohup java -jar -Dspring.profiles.active=prod /opt/www/foobar/newest.war /var/log/foobar.log 2>&1 &
You can use BUILD_ID=dontKillMe in sh step the same way
sh 'BUILD_ID=dontKillMe nohup ./deploy.sh &'
I found an another way to execute scripts and cannot be killed.
Linux service
/etc/init.d/www-project
#!/bin/bash
. /etc/init.d/functions
SERVICE_NAME="www-project"
RETVAL=0
PID=-1
PIDFILE=/var/run/${SERVICE_NAME}.PID
start () {
if [ -f ${PIDFILE} ]; then
echo "PID file ${PIDFILE} already exists, please stop the service !"
exit
fi
echo "Starting service ${SERVICE_NAME} ..."
java -jar -Dspring.profiles.active=prod /opt/www/project/newest.war > /var/log/www-project.log 2>&1 &
PID = $!
if [ -z ${PID} ]; then
echo "Failed to get the process id, exit!"
exit
else
echo "Starting successfully, whose pid is ${PID}"
fi
touch $PIDFILE
echo ${PID} > ${PIDFILE}
}
stop () {
if [ -f $PIDFILE ]; then
PID = `cat ${PIDFILE}`
if [ -z $PID ]; then
echo "PIDFILE $PIDFILE is empty!"
exit
fi
if [ -z "`ps axf | grep $PID | grep -v grep`" ]; then
echo "Process dead but pidfile exists!"
exit
else
kill -9 $PID
echo "Stopping service successfully, whose pid is $PID"
rm -f $PIDFILE
fi
else
echo "File $PIDFILE does NOT exist!"
fi
}
restart () {
stop
start
}
status () {
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z $PID ] ; then
echo "No effective pid but pidfile exists!"
else
if [ -z "`ps axf | grep $PID | grep -v grep`" ]; then
echo "Process dead but pidfile exist"
else
echo "Running"
fi
fi
else
echo "Service not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: www-project {start|stop|restart|status}"
;;
esac
systemd unit service
/usr/lib/systemd/system/www-project.service
[Unit]
Description=project
After=mysqld.service
Wants=mysqld.service
[Service]
ExecStart=/usr/lib/jvm/java/bin/java -jar -Dspring.profiles.active=prod /opt/www/project/newest.war > /var/log/www-project.log
PIDFile=/var/run/www-project.pid
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -9 $MAINPID
[Install]
WantedBy=multi-user.target
In Jenkinsfile, we can call
service restart www-project
or
systemctl restart www-project
And hudson script will never kill the services.

Java App as a Linux Service issue with permissions

I want to start my Java app as a Linux service. I created a wrapper file:
SERVICE_NAME=ConfigurationService PATH_TO_JAR=/opt/Applications/Configuration-Service/configuration-service.jar PID_PATH_NAME=/tmp/ConfigurationService-pid case $1 in
start)
echo "Starting $SERVICE_NAME ..."
if [ ! -f $PID_PATH_NAME ]; then
nohup java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null &
echo $! > $PID_PATH_NAME
echo "$SERVICE_NAME started ..."
else
echo "$SERVICE_NAME is already running ..."
fi
;;
stop)
if [ -f $PID_PATH_NAME ]; then
PID=$(cat $PID_PATH_NAME);
echo "$SERVICE_NAME stoping ..."
kill $PID;
echo "$SERVICE_NAME stopped ..."
rm $PID_PATH_NAME
else
echo "$SERVICE_NAME is not running ..."
fi
;;
restart)
if [ -f $PID_PATH_NAME ]; then
PID=$(cat $PID_PATH_NAME);
echo "$SERVICE_NAME stopping ...";
kill $PID;
echo "$SERVICE_NAME stopped ...";
rm $PID_PATH_NAME
echo "$SERVICE_NAME starting ..."
nohup java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null &
echo $! > $PID_PATH_NAME
echo "$SERVICE_NAME started ..."
else
echo "$SERVICE_NAME is not running ..."
fi
;; esac
However, when I start it with command:
service ConfigurationService start
The app start but does not have permissions to connect to DataBase. When I invoke my web API I can see such error:
There was an unexpected error (type=Internal Server Error, status=500).
Could not get JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
If I start my application using command it works without issues:
java -jar ConfigurationService.jar &
I understand that it is something related to users and permissions but I am new in Linux configuration. Appreciate any help

spring boot init.d script start-stop-daemon: unrecognized option --no-close

after symlink my app to the /etc/init.d/myappname.
/etc/init.d/myappname start gives "Failed to start"
/var/log/appname.log tells
"start-stop-daemon: unrecognized option '--no-close'"
when i remove the --no-close, the jar becomes corrupted and cannot run anymore. i am struck.
bdw my jar is fullyexecutable jar. i.e., when i run the jar alone it starts up the springboot normally.
whats going wrong here?
EDIT:
do_start() {
working_dir=$(dirname "$jarfile")
pushd "$working_dir" > /dev/null
if [[ -n "$run_user" ]]; then
mkdir "$PID_FOLDER" &> /dev/null
checkPermissions || return $?
chown "$run_user" "$PID_FOLDER"
chown "$run_user" "$pid_file"
chown "$run_user" "$log_file"
if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then
arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS "$#")
start-stop-daemon --start --quiet \
--chuid "$run_user" \
--name "$identity" \
--make-pidfile --pidfile "$pid_file" \
--background --no-close \
--startas "$javaexe" \
--chdir "$working_dir" \
-- "${arguments[#]}" \
>> "$log_file" 2>&1
await_file "$pid_file"
else
su -s /bin/sh -c "$command >> \"$log_file\" 2>&1 & echo \$!" "$run_user" > "$pid_file"
fi
pid=$(cat "$pid_file")
else
checkPermissions || return $?
$command >> "$log_file" 2>&1 &
pid=$!
disown $pid
echo "$pid" > "$pid_file"
fi
[[ -z $pid ]] && { echoRed "Failed to start"; return 1; }
echoGreen "Started [$pid]"
}
I assume you already created an executable JAR of your Spring Boot app.
Copy your app to /var/appname/appname.jar
Make sure it's given execute permission:
sudo chmod +x "/var/appname/appname.jar"
Create a config file /var/appname/appname.conf with the following content
USE_START_STOP_DAEMON=false
Follow instructions from Spring Boot Reference Guide
To install a Spring Boot application as an init.d service simply create a symlink:
$ sudo ln -s /var/appname/appname.jar /etc/init.d/appname
Once installed, you can start and stop the service in the usual way. For example, on a Debian based system:
$ service appname start
i finally solve this problem.
--no-close is a parameter that was "recently" added to start-stop-daemon
http://manpages.ubuntu.com/manpages/wily/man8/start-stop-daemon.8.html
I run my app.jar on Ubuntu 12.04 LTS that has
start-stop-daemon 1.16.1.2 for Debian
You could know what version you are running using:
start-stop-daemon --version
on linux console.
I downloaded a newer version of start-stop-daemon on
https://pkgs.org/ubuntu-14.04/ubuntu-main-amd64/dpkg_1.17.5ubuntu5_amd64.deb.html
Install the deb package and spring boot jar will finally run.
Run "service myappname start" as mentioned in the document http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html
There is a difference between /etc/init.d/myappname start and server myappname start

Tomcat start and stop using shell script?

I have below shell script to stop/stop the tomcat.
#!/bin/bash
export BASE=/home/programs/jakarta-tomcat-5.0.28/bin
prog=jakarta-tomcat-5.0.28
stat() {
if [ `ps auxwwww|grep $prog|grep -v grep|wc -l` -gt 0 ]
then
echo Tomcat is running.
else
echo Tomcat is not running.
fi
}
case "$1" in
start)
if [ `ps auxwwww|grep $prog|grep -v grep|wc -l` -gt 0 ]
then
echo Tomcat seems to be running. Use the restart option.
else
$BASE/startup.sh 2>&1 > /dev/null
fi
stat
;;
stop)
$BASE/shutdown.sh 2>&1 > /dev/null
if [ `ps auxwwww|grep $prog|grep -v grep|wc -l` -gt 0 ]
then
for pid in `ps auxwww|grep $prog|grep -v grep|tr -s ' '|cut -d ' ' -f2`
do
kill -9 $pid 2>&1 > /dev/null
done
fi
stat
;;
restart)
if [ `ps auxwwww|grep $prog|grep -v grep|wc -l` -gt 0 ]
then
for pid in `ps auxwww|grep $prog|grep -v grep|tr -s ' '|cut -d ' ' -f2`
do
kill -9 $pid 2>&1 > /dev/null
done
fi
$BASE/startup.sh 2>&1 > /dev/null
stat
;;
status)
stat
;;
*)
echo "Usage: tomcat start|stop|restart|status"
esac
Now above script works with local tomcat. Now how can i modify above script to stop/start remote tomcat?
Thanks!
You could use ssh to execute a local script on the remote machine to start/stop Tomcat, so if you are in a linux terminal, you could do something like:
ssh username#remoteMachine /home/username/myScipts/start_tomcat.sh
where start_tomcat.sh would be a script in the remote machine, of course you would need a valid username/password on the remote machine, and also the remote machine would need to have sshd installed and running

Why is shutdown.sh not showing the output?

Hi when you start Jboss 6.1 with run.sh, you have have various informations displayed and it's the same when immediately after you press ctrl-c (i am talking about Linux ), but when i call shutdown.sh i only have this as output:
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion.
How can i get the full output ?
Here are the source of the two standard scripts
#!/bin/sh
### ====================================================================== ###
## ##
## JBoss Shutdown Script ##
## ##
### ====================================================================== ###
### $Id: shutdown.sh 109786 2010-12-08 18:26:01Z epbernard $ ###
# Extract the directory and the program name
# takes care of symlinks
PRG="$0"
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
DIRNAME=`dirname "$PRG"`
PROGNAME=`basename "$PRG"`
GREP="grep"
#
# Helper to complain.
#
die() {
echo "${PROGNAME}: $*"
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JBOSS_HOME" ] &&
JBOSS_HOME=`cygpath --unix "$JBOSS_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Setup JBOSS_HOME
if [ "x$JBOSS_HOME" = "x" ]; then
JBOSS_HOME=`cd $DIRNAME/..; pwd`
fi
export JBOSS_HOME
# Setup the JVM
if [ "x$JAVA" = "x" ]; then
if [ "x$JAVA_HOME" != "x" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA="java"
fi
fi
# Setup the classpath
JBOSS_BOOT_CLASSPATH="$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jbossall-client.jar"
if [ "x$JBOSS_CLASSPATH" = "x" ]; then
JBOSS_CLASSPATH="$JBOSS_BOOT_CLASSPATH"
else
JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_BOOT_CLASSPATH"
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
JBOSS_HOME=`cygpath --path --windows "$JBOSS_HOME"`
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
JBOSS_CLASSPATH=`cygpath --path --windows "$JBOSS_CLASSPATH"`
fi
# Execute the JVM
exec "$JAVA" \
$JAVA_OPTS \
-classpath $JBOSS_CLASSPATH \
org.jboss.Shutdown "$#"
#!/bin/sh
And here is the other one just to compare.
### ====================================================================== ###
## ##
## JBoss Bootstrap Script ##
## ##
### ====================================================================== ###
### $Id: run.sh 111395 2011-05-18 07:45:07Z beve $ ###
# Extract the directory and the program name
# takes care of symlinks
PRG="$0"
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
DIRNAME=`dirname "$PRG"`
PROGNAME=`basename "$PRG"`
GREP="grep"
# Use the maximum available, or set MAX_FD != -1 to use that
MAX_FD="maximum"
#
# Helper to complain.
#
warn() {
echo "${PROGNAME}: $*"
}
#
# Helper to puke.
#
die() {
warn $*
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
linux=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;
Darwin*)
darwin=true
;;
Linux)
linux=true
;;
esac
# Read an optional running configuration file
if [ "x$RUN_CONF" = "x" ]; then
RUN_CONF="$DIRNAME/run.conf"
fi
if [ -r "$RUN_CONF" ]; then
. "$RUN_CONF"
fi
# Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower
if [ "$linux" = "true" ]; then
JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JBOSS_HOME" ] &&
JBOSS_HOME=`cygpath --unix "$JBOSS_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$JAVAC_JAR" ] &&
JAVAC_JAR=`cygpath --unix "$JAVAC_JAR"`
fi
# Setup JBOSS_HOME
if [ "x$JBOSS_HOME" = "x" ]; then
# get the full path (without any relative bits)
JBOSS_HOME=`cd $DIRNAME/..; pwd`
fi
export JBOSS_HOME
# Increase the maximum file descriptors if we can
if [ "$cygwin" = "false" ]; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ "$?" -eq 0 ]; then
# Darwin does not allow RLIMIT_INFINITY on file soft limit
if [ "$darwin" = "true" -a "$MAX_FD_LIMIT" = "unlimited" ]; then
MAX_FD_LIMIT=`/usr/sbin/sysctl -n kern.maxfilesperproc`
fi
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
# use the system max
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ "$?" -ne 0 ]; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# Setup the JVM
if [ "x$JAVA" = "x" ]; then
if [ "x$JAVA_HOME" != "x" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA="java"
fi
fi
# Setup the classpath
JBOSS_BOOT_CLASSPATH="$JBOSS_HOME/bin/run.jar"
if [ ! -f "$JBOSS_BOOT_CLASSPATH" ]; then
die "Missing required file: $JBOSS_BOOT_CLASSPATH"
fi
# Tomcat uses the JDT Compiler
# Only include tools.jar if someone wants to use the JDK instead.
# compatible distribution which JAVA_HOME points to
JAVAC_JAR_FILE="${JAVAC_JAR:-$JAVA_HOME/lib/tools.jar}"
if [ ! -f "$JAVAC_JAR_FILE" ]; then
# MacOSX does not have a seperate tools.jar
if [ "$darwin" != "true" -a "x$JAVAC_JAR" != "x" ]; then
warn "Missing file: JAVAC_JAR=$JAVAC_JAR"
warn "Unexpected results may occur."
fi
JAVAC_JAR_FILE=
fi
# Setup classpath
JBOSS_CLASSPATH="${JBOSS_CLASSPATH:+$JBOSS_CLASSPATH:$JBOSS_BOOT_CLASSPATH}"
JBOSS_CLASSPATH="${JBOSS_CLASSPATH:-$JBOSS_BOOT_CLASSPATH}"
JBOSS_CLASSPATH="$JBOSS_CLASSPATH${JAVAC_JAR_FILE:+:$JAVAC_JAR_FILE}"
# Check for -d32/-d64 in JAVA_OPTS
JVM_OPTVERSION="-version"
JVM_D64_OPTION=`echo $JAVA_OPTS | $GREP "\-d64"`
JVM_D32_OPTION=`echo $JAVA_OPTS | $GREP "\-d32"`
test "x$JVM_D64_OPTION" != "x" && JVM_OPTVERSION="-d64 $JVM_OPTVERSION"
test "x$JVM_D32_OPTION" != "x" && JVM_OPTVERSION="-d32 $JVM_OPTVERSION"
# If -server not set in JAVA_OPTS, set it, if supported
SERVER_SET=`echo $JAVA_OPTS | $GREP "\-server"`
if [ "x$SERVER_SET" = "x" ]; then
# Check for SUN(tm) JVM w/ HotSpot support
if [ "x$HAS_HOTSPOT" = "x" ]; then
HAS_HOTSPOT=`"$JAVA" $JVM_OPTVERSION -version 2>&1 | $GREP -i HotSpot`
fi
# Check for OpenJDK JVM w/server support
if [ "x$HAS_OPENJDK_" = "x" ]; then
HAS_OPENJDK=`"$JAVA" $JVM_OPTVERSION 2>&1 | $GREP -i OpenJDK`
fi
# Enable -server if we have Hotspot or OpenJDK, unless we can't
if [ "x$HAS_HOTSPOT" != "x" -o "x$HAS_OPENJDK" != "x" ]; then
# MacOS does not support -server flag
if [ "$darwin" != "true" ]; then
JAVA_OPTS="-server $JAVA_OPTS"
JVM_OPTVERSION="-server $JVM_OPTVERSION"
fi
fi
else
JVM_OPTVERSION="-server $JVM_OPTVERSION"
fi
# Setup JBoss specific properties
JAVA_OPTS="${JAVA_OPTS:+$JAVA_OPTS -Dprogram.name=$PROGNAME}"
JAVA_OPTS="${JAVA_OPTS:--Dprogram.name=$PROGNAME}"
JAVA_OPTS="${JAVA_OPTS:+$JAVA_OPTS -Dlogging.configuration=file:${DIRNAME}/logging.properties}"
# Setup JBoss Native library path
#
if [ -d "$JBOSS_HOME/../native/lib" ]; then
JBOSS_NATIVE_DIR=`cd "$JBOSS_HOME/../native" && pwd`
elif [ -d "$JBOSS_HOME/native/lib" ]; then
JBOSS_NATIVE_DIR=`cd "$JBOSS_HOME/native" && pwd`
elif [ -d "$JBOSS_HOME/../native/lib64" ]; then
JBOSS_NATIVE_DIR=`cd "$JBOSS_HOME/../native" && pwd`
elif [ -d "$JBOSS_HOME/native/lib64" ]; then
JBOSS_NATIVE_DIR=`cd "$JBOSS_HOME/native" && pwd`
elif [ -d "$JBOSS_HOME/native/bin" ]; then
JBOSS_NATIVE_DIR=`cd "$JBOSS_HOME/native" && pwd`
elif [ -d "$JBOSS_HOME/bin/native" ]; then
JBOSS_NATIVE_DIR=`cd "$JBOSS_HOME/bin/native" && pwd`
fi
if [ -d "$JBOSS_NATIVE_DIR" ]; then
if $cygwin; then
JBOSS_NATIVE_DIR="$JBOSS_NATIVE_DIR/bin"
export PATH="$JBOSS_NATIVE_DIR:$PATH"
JBOSS_NATIVE_LIBPATH=`cygpath --path --windows "$JBOSS_NATIVE_DIR"`
else
IS_64_BIT_JVM=`"$JAVA" $JVM_OPTVERSION 2>&1 | $GREP -i 64-bit`
if [ "x$IS_64_BIT_JVM" != "x" ]; then
JBOSS_NATIVE_DIR="$JBOSS_NATIVE_DIR/lib64"
else
JBOSS_NATIVE_DIR="$JBOSS_NATIVE_DIR/lib"
fi
LD_LIBRARY_PATH="$JBOSS_NATIVE_DIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH
JBOSS_NATIVE_LIBPATH=$LD_LIBRARY_PATH
fi
JAVA_OPTS="$JAVA_OPTS -Djava.library.path=$JBOSS_NATIVE_LIBPATH"
fi
# Setup the java endorsed dirs
JBOSS_ENDORSED_DIRS="$JBOSS_HOME/lib/endorsed"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
JBOSS_HOME=`cygpath --path --windows "$JBOSS_HOME"`
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
JBOSS_CLASSPATH=`cygpath --path --windows "$JBOSS_CLASSPATH"`
JBOSS_ENDORSED_DIRS=`cygpath --path --windows "$JBOSS_ENDORSED_DIRS"`
fi
# Display our environment
echo "========================================================================="
echo ""
echo " JBoss Bootstrap Environment"
echo ""
echo " JBOSS_HOME: $JBOSS_HOME"
echo ""
echo " JAVA: $JAVA"
echo ""
echo " JAVA_OPTS: $JAVA_OPTS"
echo ""
echo " CLASSPATH: $JBOSS_CLASSPATH"
echo ""
echo "========================================================================="
echo ""
while true; do
if [ "x$LAUNCH_JBOSS_IN_BACKGROUND" = "x" ]; then
# Execute the JVM in the foreground
eval \"$JAVA\" $JAVA_OPTS \
-Djava.endorsed.dirs=\"$JBOSS_ENDORSED_DIRS\" \
-classpath \"$JBOSS_CLASSPATH\" \
org.jboss.Main "$#"
JBOSS_STATUS=$?
else
# Execute the JVM in the background
eval \"$JAVA\" $JAVA_OPTS \
-Djava.endorsed.dirs=\"$JBOSS_ENDORSED_DIRS\" \
-classpath \"$JBOSS_CLASSPATH\" \
org.jboss.Main "$#" "&"
JBOSS_PID=$!
# Trap common signals and relay them to the jboss process
trap "kill -HUP $JBOSS_PID" HUP
trap "kill -TERM $JBOSS_PID" INT
trap "kill -QUIT $JBOSS_PID" QUIT
trap "kill -PIPE $JBOSS_PID" PIPE
trap "kill -TERM $JBOSS_PID" TERM
if [ "x$JBOSS_PIDFILE" != "x" ]; then
echo $JBOSS_PID > $JBOSS_PIDFILE
fi
# Wait until the background process exits
WAIT_STATUS=128
while [ "$WAIT_STATUS" -ge 128 ]; do
wait $JBOSS_PID 2>/dev/null
WAIT_STATUS=$?
if [ "$WAIT_STATUS" -gt 128 ]; then
SIGNAL=`expr $WAIT_STATUS - 128`
SIGNAL_NAME=`kill -l $SIGNAL`
echo "*** JBossAS process ($JBOSS_PID) received $SIGNAL_NAME signal ***" >&2
fi
done
if [ "$WAIT_STATUS" -lt 127 ]; then
JBOSS_STATUS=$WAIT_STATUS
else
JBOSS_STATUS=0
fi
if [ "$JBOSS_STATUS" -ne 10 ]; then
# Wait for a complete shudown
wait $JBOSS_PID 2>/dev/null
fi
fi
# If restart doesn't work, check you are running JBossAS 4.0.4+
# http://jira.jboss.com/jira/browse/JBAS-2483
# or the following if you're running Red Hat 7.0
# http://developer.java.sun.com/developer/bugParade/bugs/4465334.html
if [ "$JBOSS_STATUS" -eq 10 ]; then
echo "Restarting JBoss..."
else
exit $JBOSS_STATUS
fi
done
The JBoss shutdown script just posts a shutdown message to the server. The log that you get when you originally started the server (log file, console etc) will continue to log info while shutting down.
The org.jboss.Shutdown class is designed to not output anything to the console. What you are seeing is all that the program will ever output. If you need more information, check the log files. And if that is not enough, consider adjusting the JBoss logging level.
You can confirm this by looking at the source code.
Note that this program doesn't do the shutdown. What it actually does is to send a request to the server to tell it to shutdown. The server takes care of the rest ... asynchronously.

Categories