Start Stop War-Ear programmatically in JBoss-5
forum.khan Feb 3, 2013 11:27 PMHi,
Below is the script to start and stop the war/ear in Jboss programmatically. With this script am facing the below issue. Can anyone please let me know the changes that need to be done.
Issues:
1. When EAR is running, if i again try to start it will be automatically undeployed. Couldnt find the way to know that the EAR is running so that i dont need to run the start command. Deployed and Running are different which can be monitored from the JBoss JMX console.
2. In JMX console the ear's will display the service and Mbean. These are displayed in alphabetical order. In case if the Mbean is displayed before the service it fails to stop the ear with a message, as the command are executed on the mbean.
"ERROR [Twiddle] Command failure org.jboss.console.twiddle.command.CommandException: MBean has no such operation named 'stop' with signature compatible with: [] at org.jboss.console.twiddle.command.InvokeCommand.invoke(InvokeCommand.java:217) at org.jboss.console.twiddle.command.InvokeCommand.execute(InvokeCommand.java:291) at org.jboss.console.twiddle.Twiddle.main(Twiddle.java:306) Invoke an operation on an MBean usage: invoke [options] <query> <operation> (<arg>)* options: -q, --query-type[=<type>] Treat object name as a query -- Stop processing options query type: f[irst] Only invoke on the first matching name [default] a[ll] Invoke on all matching names tools>"
3. In script we need to use Jboss twiddle.sh file. Please let me know how to achieve the below operation(start/stop) in java without using twiddle.sh file as even Jboss is in Java.
start-stop war: http://nirvikalpa.wordpress.com/2010/08/25/start-stop-web-application-on-jboss-twiddle/
start-stop ear:
export JBOSS_HOME="D:/jboss-as"
export TWIDDLE="$JBOSS_HOME/bin/twiddle.sh"
echo $JBOSS_HOME
echo $TWIDDLE
if test $# -lt 4
then
echo "Please enter the user,password,application ear name and the start/stop op"
else
app=$($TWIDDLE -s 127.0.0.1 -u $1 -p $2 query 'jboss.j2ee:*' | grep $3)
app=`echo $app | sed 's/\r//g'`
if [ "${app}" == "" ]
then
echo "Application doesnt exit"
exit -1
fi
if [ "$4" == "start" ]
then
echo "Starting ............"
doop=$($TWIDDLE -s 127.0.0.1 -u $1 -p $2 invoke jboss.j2ee:ear=$3,* $4 )
fi
if [ "$4" == "stop" ]
then
echo "Stopping ............"
doop=$($TWIDDLE -s 127.0.0.1 -u $1 -p $2 invoke jboss.j2ee:ear=$3,* $4 )
fi
fi