When running a Jython script to control the state of an Application Deployed to a Standalone Liberty Profile server, we get the following error:
TypeError: javax.management.remote.JMXServiceURL(): 3rd arg can't be coerced to int
root@node01 standalone]# ./controlApp.sh status HelloWorld-0.0.1-SNAPSHOT Environment Settings PATH=/opt/ibm/java-x86_64-80/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/var/apps/jython_2.7.0/bin WLP_INSTALL_DIR=/var/apps/waslp_DV01/wlp JYTHON_SCRIPTS=/var/apps/scripts/liberty CLASSPATH=/var/apps/waslp_DV01/wlp/clients/restConnector.jar JYTHONPATH=/var/apps/waslp_DV01/wlp/clients/jython:/var/apps/scripts/liberty/lib script parameters ACTION=status APP_NAME=HelloWorld-0.0.1-SNAPSHOT Server settings.. SERVER_NAME=server1 TRUST_STORE=/var/apps/waslp_DV01/wlp/usr/servers/server1/resources/security/key.jks TRUST_STORE_PASSWORD=Liberty HOST=192.168.0.40 PORT=9443 USER_NAME=wasadmin USER_PASSWORD=wasadmin Executing CMD: jython controlApp.py status HelloWorld-0.0.1-SNAPSHOT /var/apps/waslp_DV01/wlp/usr/servers/server1/resources/security/key.jks Liberty 192.168.0.40 9443 wasadmin wasadmin MAIN:BEGIN varName=controlApp.py varValue=status action=%s controlApp.py appName=%s status trustStore=%s HelloWorld-0.0.1-SNAPSHOT trustStorePassword=%s /var/apps/waslp_DV01/wlp/usr/servers/server1/resources/security/key.jks hostname=%s Liberty port=%s 192.168.0.40 username=%s 9443 password=%s wasadmin Connecting to the server... Traceback (most recent call last): File "controlApp.py", line 57, in <module> _mBeanConnection = getConnection( File "controlApp.py", line 21, in getConnection connector.connect(hostname, port, username, password) File "/var/apps/waslp_DV01/wlp/clients/jython/restConnector.py", line 57, in connect self.connectBasic(host, port, args[0], args[1]) File "/var/apps/waslp_DV01/wlp/clients/jython/restConnector.py", line 76, in connectBasic self.connectAdvanced(host, port, map) File "/var/apps/waslp_DV01/wlp/clients/jython/restConnector.py", line 65, in connectAdvanced url = JMXServiceURL("REST", host, port, "/IBMJMXConnectorREST") TypeError: javax.management.remote.JMXServiceURL(): 3rd arg can't be coerced to int
The reason for this is the line of code in the Jython script that create a connection to the Liberty Server’s JMX interface (WebSphere:service=com.ibm.websphere.application.ApplicationMBean,name=*) is a string not an int i.e. the port number was passed as string not int
def getConnection(trustStore, trustStorePassword, hostname, port, username, password) : JMXRESTConnector.trustStore = trustStore JMXRESTConnector.trustStorePassword = trustStorePassword connector = JMXRESTConnector() connector.connect(hostname, port, username, password) mconnection = connector.getMBeanServerConnection() return mconnection #endDef
The code was changed from
_mBeanConnection = getConnection( trustStore, trustStorePassword, hostname, port, username, password)
to
_mBeanConnection = getConnection( trustStore, trustStorePassword, hostname, int(port), username, password)






