|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
ANT SSHEXEC WSADMIN stopApplication command error |
« View previous topic :: View next topic » |
Author |
Message
|
bobbee |
Posted: Tue Mar 07, 2017 5:06 am Post subject: ANT SSHEXEC WSADMIN stopApplication command error |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 545 Location: Tampa
|
I have an ANT script that builds a JAR and it then FTP's it to the server. The application then requires a recycle. I have been trying REMOTELY to restart the app. I was trying WSADMIN then I tried to use the WS_ANT tasks unsuccessfully. I am back at the SSHEXEC implementation.
Here is the ANT Script:
Code: |
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="FinancialHandler">
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.7" />
<property name="source" value="1.7" />
<property name="target.SDLC" value="UNIT"
description="SDLC Cycle = ${target.SDLC}" />
<!--Start FTP Properties -->
<!--
<property name="source-directory" value="dist\lib" />
<property name="ftp-server" value="SERVER_GOES_HERE" />
<property name="ftp-userid" value="USERID_GOES_HERE" />
<property name="ftp-password" value="PASSWORD_GOES_HERE" />
<property name="ftp-remotedir" value="REMOTE_DIR_GOES_HERE" />
<property name="jar-file-name" value="jarFileName" />
-->
<!--End FTP Properties -->
<property name="my.PROPS.file" location="Props/${target.SDLC}.props"/>
<echo message="My abs path is : ${my.PROPS.file}"/>
<property file="${my.PROPS.file}"
description="Properties file for FTP"/>
<echo message="target.SDLC : ${target.SDLC}" />
<echo message="ftp-server : ${ftp-server}" />
<echo message="ftp-remotedir : ${ftp-remotedir}" />
<echo message="ftp-userid : ${ftp-userid}" />
<!-- <echo message="ftp-password : ${ftp-password}" /> -->
<echo message="jar-file-name : ${jar-file-name}" />
<path id="Web App Libraries.libraryclasspath">
<pathelement location="WebContent/WEB-INF/lib/axis.jar" />
<pathelement location="WebContent/WEB-INF/lib/commons-discovery-0.2.jar" />
<pathelement location="WebContent/WEB-INF/lib/commons-logging.jar" />
<pathelement location="WebContent/WEB-INF/lib/jaxrpc.jar" />
<pathelement location="WebContent/WEB-INF/lib/saaj.jar" />
<pathelement location="WebContent/WEB-INF/lib/wsdl4j.jar" />
</path>
<path id="EAR Libraries.libraryclasspath" />
<path id="FinancialHandler.classpath">
<pathelement location="bin" />
<pathelement location="lib/Action_Handler.jar" />
<pathelement location="lib/CounterFraud_Common.jar" />
<pathelement location="lib/jackson-annotations-2.2.2.jar" />
<pathelement location="lib/jackson-core-2.2.2.jar" />
<pathelement location="lib/jackson-databind-2.2.2.jar" />
<pathelement location="lib/javax.ws.rs-api-2.0.jar" />
<pathelement location="lib/CounterFraud_DAO.jar" />
<pathelement location="lib/javax.servlet.jar" />
<pathelement location="lib/db2jcc_license_cu.jar" />
<pathelement location="lib/db2jcc4.jar" />
<pathelement location="lib/JSON4J_Apache.jar" />
<pathelement location="C:/eclipse/plugins/org.apache.axis_1.4.0.v201005080400/lib/axis.jar" />
<pathelement location="C:/eclipse/plugins/org.apache.commons.discovery_0.2.0.v201004190315/lib/commons-discovery-0.2.jar" />
<pathelement location="C:/eclipse/plugins/javax.xml.rpc_1.1.0.v201005080400/lib/jaxrpc.jar" />
<pathelement location="C:/eclipse/plugins/javax.xml.soap_1.2.0.v201005080501/lib/saaj.jar" />
<pathelement location="C:/eclipse/plugins/javax.wsdl_1.6.2.v201012040545.jar" />
<pathelement location="C:/eclipse/plugins/org.apache.commons.logging_1.0.4.v201101211617.jar" />
<pathelement location="lib/com.ibm.ws.runtime.jar" />
<path refid="Web App Libraries.libraryclasspath" />
<path refid="EAR Libraries.libraryclasspath" />
</path>
<target name="clean">
<delete dir="bin" />
<delete dir="dist" />
</target>
<target depends="clean" name="init">
<mkdir dir="bin" />
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch" />
<exclude name="**/*.java" />
</fileset>
</copy>
<mkdir dir="dist" />
<!-- Display Operating Environment -->
<!-- <echoproperties/> -->
</target>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}" />
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
<src path="src" />
<classpath refid="FinancialHandler.classpath" />
</javac>
</target>
<target name="copyHelperJars">
<copy file="lib/Action_Handler.jar" todir="dist" />
<copy file="lib/javax.servlet.jar" todir="dist" />
<copy file="lib/javax.ws.rs-api-2.0.jar" todir="dist" />
<copy todir="dist\lib">
<fileset dir="lib"/>
</copy>
</target>
<!--
<target name="sftp" description="upload JAR file to server">
<sftp
server="${ftp-server}" remotedir="${ftp-remotedir}"
userid="${ftp-userid}" password="${ftp-password}"
action="send" verbose="yes" depends="yes">
<fileset file="dist/${jar-file-name}" />
</sftp>
</target>
-->
<target name="sftp">
<scp todir="${ftp-userid}:${ftp-password}@${ftp-server}:/${ftp-remotedir}" sftp="true" trust="true" >
<fileset dir="dist/">
<include name="${jar-file-name}"/>
</fileset>
</scp>
</target>
<target depends="copyHelperJars" name="jar">
<jar destfile="dist\FinancialHandler.jar" basedir="bin">
<manifest>
<attribute name="Main-Class" value="" />
</manifest>
</jar>
</target>
<property name="sshexec.host" value="" />
<property name="sshexec.username" value="" />
<property name="sshexec.password" value="" />
<property name="sshexec.trust" value="true" />
<property name="sshexec.failonerror" value="true" />
<property name="sshexec.timeout" value="0" />
<property name="sshexec.outputproperty" value="0" />
<!-- <property name="sshexec.command" value="/opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -c 'AdminControl.invoke(AdminControl.queryNames( 'type=ApplicationManager,*','stopApplication','CounterFraud_Engine')' -lang jython" /> -->
<!-- <property name="sshexec.command" value="/opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -c 'AdminControl.invoke(AdminControl.queryNames('type=Server'),'stopApplication','CounterFraud_Engine')' -lang jython" /> -->
<!-- <property name="sshexec.command" value="/opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -c 'AdminControl.invoke(ApplicationManager, 'stopApplication', 'CounterFraud_Engine')' -lang jython" /> -->
<property name="sshexec.command" value="/opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -c 'AdminControl.invoke(AdminControl.queryNames('cell=CoreCell,node=CoreWebNode,type=ApplicationManager,process=ICFMServer,*'),'stopApplication','CounterFraud_Engine')' -lang jython" />
<echo message="sshexec.command : ${sshexec.command}" />
<target name="sshexec" description="SSHExec">
<sshexec host="${ftp-server}" username="${ftp-userid}" password="${ftp-password}" trust="yes" failonerror="${sshexec.failonerror}" timeout="${sshexec.timeout}" command="${sshexec.command}" outputproperty="sshexec.outputproperty" />
</target>
<!-- <taskdef name="wsStopApp" classname="com.ibm.websphere.ant.tasks.StopApplication" />
<target name="stopApplication">
<taskdef name="wsStopApp" classname="com.ibm.websphere.ant.tasks.StopApplication"/>
<wsStopApp application="CounterFraud_Engine"
host="${ftp-server}" port="80" conntype="SOAP" user="${ftp-userid}" password="${ftp-password}"
server="ICFMServer" node="CoreWebNode"/>
<classpath refid="FinancialHandler.classpath" />
</target>
-->
<target depends="build-project,jar, sftp, sshexec" name="build" />
</project>
|
Everything goes fine till the SSHEXEC task. I then receive this error:
Code: |
Buildfile: C:\JAZZ_BUILD\US Check\FinancialHandler\build.xml
[echo] My abs path is : C:\JAZZ_BUILD\US Check\FinancialHandler\Props\TempDev.props
[echo] target.SDLC : TempDev
[echo] ftp-server : core2.icfm.ibm.com
[echo] ftp-remotedir : /tmp
[echo] ftp-userid : wasmgr
[echo] jar-file-name : FinancialHandler.jar
[echo] sshexec.command : /opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -c 'AdminControl.invoke(AdminControl.queryNames('cell=CoreCell,node=CoreWebNode,type=ApplicationManager,process=ICFMServer,*'),'stopApplication','CounterFraud_Engine')' -lang jython
clean:
init:
[mkdir] Created dir: C:\JAZZ_BUILD\US Check\FinancialHandler\bin
[copy] Copying 14 files to C:\JAZZ_BUILD\US Check\FinancialHandler\bin
[mkdir] Created dir: C:\JAZZ_BUILD\US Check\FinancialHandler\dist
build-project:
[echo] FinancialHandler: C:\JAZZ_BUILD\US Check\FinancialHandler\build.xml
[javac] Compiling 464 source files to C:\JAZZ_BUILD\US Check\FinancialHandler\bin
copyHelperJars:
[copy] Copying 1 file to C:\JAZZ_BUILD\US Check\FinancialHandler\dist
[copy] Copying 1 file to C:\JAZZ_BUILD\US Check\FinancialHandler\dist
[copy] Copying 1 file to C:\JAZZ_BUILD\US Check\FinancialHandler\dist
[copy] Copying 12 files to C:\JAZZ_BUILD\US Check\FinancialHandler\dist\lib
jar:
[jar] Building jar: C:\JAZZ_BUILD\US Check\FinancialHandler\dist\FinancialHandler.jar
sftp:
[scp] Connecting to core2.icfm.ibm.com:22
[scp] done.
sshexec:
[sshexec] Connecting to core2.icfm.ibm.com:22
[sshexec] cmd : /opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -c 'AdminControl.invoke(AdminControl.queryNames('cell=CoreCell,node=CoreWebNode,type=ApplicationManager,process=ICFMServer,*'),'stopApplication','CounterFraud_Engine')' -lang jython
[sshexec] WASX7209I: Connected to process "dmgr" on node CoreNode using SOAP connector; The type of process is: DeploymentManager
[sshexec] Traceback (innermost last):
[sshexec] (no code object) at line 0
[sshexec] File "<input>", line 1
[sshexec] AdminControl.invoke(AdminControl.queryNames(cell=CoreCell,node=CoreWebNode,type=ApplicationManager,process=ICFMServer,*),stopApplication,CounterFraud_Engine)
[sshexec] ^
[sshexec] SyntaxError: invalid syntax
build:
BUILD SUCCESSFUL
Total time: 23 seconds
|
The 'carrot', if not showing in the cut and paste, is under the closing Paren on the AdminControl.queryNames parameter list.
Any suggestions? |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 07, 2017 1:42 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Could you potentially have a problem with the quotes:
'.....('...','...','...')...' ??
Have you tried making the outer single quotes doubles or escaping them?
see
Code: |
sshexec.command : /opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -c 'AdminControl.invoke(AdminControl.queryNames('cell=CoreCell,node=CoreWebNode,type=ApplicationManager,process=ICFMServer,*'),'stopApplication','CounterFraud_Engine')' -lang jython |
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
bobbee |
Posted: Tue Mar 07, 2017 1:59 pm Post subject: |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 545 Location: Tampa
|
If I put double quotes inside it the editor throws errors. I have escaped with "e;. this did not work. the part:
cell=CoreCell,node=CoreWebNode,type=ApplicationManager,process=ICFMServer,*
has to be encased in single quotes and passed in. Have not accomplished this yet. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 07, 2017 2:02 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you tried escaping the quote as \' ? Or setting the outer quotes as double quotes? Do they all have to be single quotes? Have you tried running the command outside of sshexec shell?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
bobbee |
Posted: Tue Mar 07, 2017 2:19 pm Post subject: |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 545 Location: Tampa
|
GOT IT !!!!
Code: |
<property name="sshexec.command" value="/opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -lang jython -c 'AdminControl.completeObjectName("'cell=CoreCell,node=ICFMNode,type=ApplicationManager,process=ICFMServer,*'")'" />
|
|
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 07, 2017 2:22 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Thanks for sharing the solution  _________________ MQ & Broker admin |
|
Back to top |
|
 |
bobbee |
Posted: Tue Mar 07, 2017 2:54 pm Post subject: |
|
|
 Knight
Joined: 20 Sep 2001 Posts: 545 Location: Tampa
|
Here is the full ANT script, Compiles JAVA to a JAR, FTP's it to the server, then recycles the application.
Code: |
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="FinancialHandler">
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.7" />
<property name="source" value="1.7" />
<property name="target.SDLC" value="UNIT"
description="SDLC Cycle = ${target.SDLC}" />
<!--Start FTP Properties -->
<!--
<property name="source-directory" value="dist\lib" />
<property name="ftp-server" value="SERVER_GOES_HERE" />
<property name="ftp-userid" value="USERID_GOES_HERE" />
<property name="ftp-password" value="PASSWORD_GOES_HERE" />
<property name="ftp-remotedir" value="REMOTE_DIR_GOES_HERE" />
<property name="jar-file-name" value="jarFileName" />
-->
<!--End FTP Properties -->
<property name="my.PROPS.file" location="Props/${target.SDLC}.props"/>
<echo message="My abs path is : ${my.PROPS.file}"/>
<property file="${my.PROPS.file}"
description="Properties file for FTP"/>
<echo message="target.SDLC : ${target.SDLC}" />
<echo message="ftp-server : ${ftp-server}" />
<echo message="ftp-remotedir : ${ftp-remotedir}" />
<echo message="ftp-userid : ${ftp-userid}" />
<!-- <echo message="ftp-password : ${ftp-password}" /> -->
<echo message="jar-file-name : ${jar-file-name}" />
<path id="Web App Libraries.libraryclasspath">
<pathelement location="WebContent/WEB-INF/lib/axis.jar" />
<pathelement location="WebContent/WEB-INF/lib/commons-discovery-0.2.jar" />
<pathelement location="WebContent/WEB-INF/lib/commons-logging.jar" />
<pathelement location="WebContent/WEB-INF/lib/jaxrpc.jar" />
<pathelement location="WebContent/WEB-INF/lib/saaj.jar" />
<pathelement location="WebContent/WEB-INF/lib/wsdl4j.jar" />
</path>
<path id="EAR Libraries.libraryclasspath" />
<path id="FinancialHandler.classpath">
<pathelement location="bin" />
<pathelement location="lib/Action_Handler.jar" />
<pathelement location="lib/CounterFraud_Common.jar" />
<pathelement location="lib/jackson-annotations-2.2.2.jar" />
<pathelement location="lib/jackson-core-2.2.2.jar" />
<pathelement location="lib/jackson-databind-2.2.2.jar" />
<pathelement location="lib/javax.ws.rs-api-2.0.jar" />
<pathelement location="lib/CounterFraud_DAO.jar" />
<pathelement location="lib/javax.servlet.jar" />
<pathelement location="lib/db2jcc_license_cu.jar" />
<pathelement location="lib/db2jcc4.jar" />
<pathelement location="lib/JSON4J_Apache.jar" />
<pathelement location="C:/eclipse/plugins/org.apache.axis_1.4.0.v201005080400/lib/axis.jar" />
<pathelement location="C:/eclipse/plugins/org.apache.commons.discovery_0.2.0.v201004190315/lib/commons-discovery-0.2.jar" />
<pathelement location="C:/eclipse/plugins/javax.xml.rpc_1.1.0.v201005080400/lib/jaxrpc.jar" />
<pathelement location="C:/eclipse/plugins/javax.xml.soap_1.2.0.v201005080501/lib/saaj.jar" />
<pathelement location="C:/eclipse/plugins/javax.wsdl_1.6.2.v201012040545.jar" />
<pathelement location="C:/eclipse/plugins/org.apache.commons.logging_1.0.4.v201101211617.jar" />
<pathelement location="lib/com.ibm.ws.runtime.jar" />
<path refid="Web App Libraries.libraryclasspath" />
<path refid="EAR Libraries.libraryclasspath" />
</path>
<target name="clean">
<delete dir="bin" />
<delete dir="dist" />
</target>
<target depends="clean" name="init">
<mkdir dir="bin" />
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch" />
<exclude name="**/*.java" />
</fileset>
</copy>
<mkdir dir="dist" />
<!-- Display Operating Environment -->
<!-- <echoproperties/> -->
</target>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}" />
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
<src path="src" />
<classpath refid="FinancialHandler.classpath" />
</javac>
</target>
<target name="copyHelperJars">
<copy file="lib/Action_Handler.jar" todir="dist" />
<copy file="lib/javax.servlet.jar" todir="dist" />
<copy file="lib/javax.ws.rs-api-2.0.jar" todir="dist" />
<copy todir="dist\lib">
<fileset dir="lib"/>
</copy>
</target>
<!--
<target name="sftp" description="upload JAR file to server">
<sftp
server="${ftp-server}" remotedir="${ftp-remotedir}"
userid="${ftp-userid}" password="${ftp-password}"
action="send" verbose="yes" depends="yes">
<fileset file="dist/${jar-file-name}" />
</sftp>
</target>
-->
<target name="sftp">
<scp todir="${ftp-userid}:${ftp-password}@${ftp-server}:/${ftp-remotedir}" sftp="true" trust="true" >
<fileset dir="dist/">
<include name="${jar-file-name}"/>
</fileset>
</scp>
</target>
<target depends="copyHelperJars" name="jar">
<jar destfile="dist\FinancialHandler.jar" basedir="bin">
<manifest>
<attribute name="Main-Class" value="" />
</manifest>
</jar>
</target>
<property name="sshexec.trust" value="true" />
<property name="sshexec.failonerror" value="true" />
<property name="sshexec.stop.command" value="/opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -lang jython -c 'AdminControl.invoke(AdminControl.completeObjectName("'cell=CoreCell,node=ICFMNode,type=ApplicationManager,process=ICFMServer,*'"), "'stopApplication'", "'CounterFraud_Engine'")'" />
<property name="sshexec.start.command" value="/opt/IBM/WebSphere/AppServer/profiles/ICFMProfile/bin/wsadmin.sh -lang jython -c 'AdminControl.invoke(AdminControl.completeObjectName("'cell=CoreCell,node=ICFMNode,type=ApplicationManager,process=ICFMServer,*'"), "'startApplication'", "'CounterFraud_Engine'")'" />
<echo message="sshexec.command : ${sshexec.command}" />
<target name="sshexec.recycle.CounterFraud_Engine" description="SSHExec">
<sshexec host="${ftp-server}" username="${ftp-userid}" password="${ftp-password}" trust="yes" failonerror="${sshexec.failonerror}" timeout="${sshexec.timeout}" command="${sshexec.stop.command}" outputproperty="sshexec.AppManagement" />
<echo message="sshexec.AppManagement : ${sshexec.AppManagement}" />
<sshexec host="${ftp-server}" username="${ftp-userid}" password="${ftp-password}" trust="yes" failonerror="${sshexec.failonerror}" timeout="${sshexec.timeout}" command="${sshexec.start.command}" outputproperty="sshexec.AppManagement" />
<echo message="sshexec.AppManagement : ${sshexec.AppManagement}" />
</target>
<target depends="build-project,jar, sftp, sshexec.recycle.CounterFraud_Engine" name="build" />
</project>
|
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|