LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-29-2009, 04:55 PM   #1
socal_javaguy
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
Unhappy How to run JBoss 5 as a Service / Daemon on Fedora 8?


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/:

Code:
#!/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:

Code:
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):

Code:
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):

Code:
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) In addition, I am unable to do this:

chkconfig --add jboss

"service jboss does not support chkconfig"

(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...
 
Old 07-31-2009, 11:30 AM   #2
camh
Member
 
Registered: Feb 2005
Distribution: Slack/Debian
Posts: 163
Blog Entries: 2

Rep: Reputation: 33
I might be way off (or missing something), but I can't see anywhere that $JAVA is defined..

When running it locally maybe you already have it defined (through .bashrc, .profile, etc.). However, from the 'service' man page:
Code:
ENVIRONMENT
       LANG, TERM
              The only environment variables passed to the init scripts.
Maybe defining

Code:
JAVA=/usr/java/jdk/bin/java
in your /etc/init.d script will work?
 
  


Reply

Tags
daemon, fedora, jboss, linux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run JBoss App as a service at a given time netjack Linux - Server 3 12-05-2007 12:02 PM
Enable daemon to run with service daemon start,etc baddah Programming 6 12-02-2007 05:51 PM
How to make TCP server a daemon / service much like a dhcpd service? rajat Linux - Networking 1 05-22-2007 01:29 AM
jboss daemon hvdwatt Linux - General 6 01-10-2005 10:11 AM
jboss daemon yenonn Linux - General 0 04-29-2004 08:35 PM


All times are GMT -5. The time now is 03:04 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration