Liberty Profile Jython automation – TypeError – javax.management.remote.JMXServiceURL() – 3rd arg can’t be coerced to int

转载自: http://www.themiddlewareshop.com/2016/03/24/liberty-profile-jython-automation-typeerror-javax-management-remote-jmxserviceurl-3rd-arg-cant-be-coerced-to-int/

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

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

1

2

3

4

5

6

7

8

9

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)

1

2

3

4

5

6

7

_mBeanConnection  = getConnection(

trustStore,

trustStorePassword,

hostname,

port,

username,

password)

to

_mBeanConnection = getConnection(
trustStore,
trustStorePassword,
hostname,
int(port),
username,
password)

1

2

3

4

5

6

7

_mBeanConnection  = getConnection(

trustStore,

trustStorePassword,

hostname,

int(port),

username,

password)

时间: 2024-08-06 07:56:38

Liberty Profile Jython automation – TypeError – javax.management.remote.JMXServiceURL() – 3rd arg can’t be coerced to int的相关文章

druid抛出的异常------javax.management.InstanceAlreadyExistsException引发的一系列探索

最近项目中有个定时任务的需求,定时检查mysql数据与etcd数据的一致性,具体实现细节就不说了,今天要说的就是实现过程中遇到了druid抛出的异常,以及解决的过程 异常 异常详细信息 五月 05, 2017 4:16:00 下午 com.alibaba.druid.proxy.DruidDriver warn 警告: register druid-driver mbean error javax.management.InstanceAlreadyExistsException: com.al

jedis报LinkageError错误:javax/management/MBeanServer

使用jedis客户端时,遇到下面异常信息: Horrible Exception: java.lang.LinkageError: loading constraint violation: loader "com/ibm/ws/classloader/[email protected]" previously initiated loading for a different type with name "javax/management/MBeanServer"

javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat解决方案

ERROR [com.alibaba.druid.stat.DruidDataSourceStatManager] – unregister mbean errorjavax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStatat com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean--- 原因:在一台服务器上启动了

Tomcat:javax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStat异常

问题: 在关闭tomcat时: Tomat报出一下异常:ERROR [com.alibaba.druid.stat.DruidDataSourceStatManager] – unregister mbean errorjavax.management.InstanceNotFoundException: com.alibaba.druid:type=DruidDataSourceStatat com.sun.jmx.interceptor.DefaultMBeanServerIntercept

kafka javax.management.InstanceAlreadyExistsException: kafka.consumer:type=app-info,id=consumer-1

错误日志: 2019-10-11 17:50:48.744 WARN []-[o.a.k.clients.consumer.ConsumerConfig :173] The configuration num.replica.fetchers = 1 was supplied but isn't a known config.2019-10-11 17:50:48.747 INFO []-[o.a.kafka.common.utils.AppInfoParser :82] Kafka versi

javax.management.NotCompliantMBeanException

public interface QueueMBean { } 假如接口名叫 XMBean ,那么实现名就必须一定是X,而且是大小写敏感的. public class Queue implements QueueMBean { }

druid抛出异常:javax.management.InstanceAlreadyExistsException: com.alibaba.druid:type=DruidDataSource,id=xxx

参考: https://www.cnblogs.com/youzhibing/p/6826767.html 结论: 问题产生的根本原因还真是:同一实例被启动了两遍,Path为/SLBAdmin启动一次,Path为/wgp-Web启动一次, 开发过程中最好保证工程名与发布路径保证一直,避免不必要的麻烦 原文地址:https://www.cnblogs.com/moly/p/8308871.html

Hierarchy For Package javax.management

java.lang.ObjectgetClass    public final Class<?> getClass()Java的每个类都带有一个运行时类对象,该Class对象中保存了创建对象所需的所有信息.可以用.class返回此 Object 的运行时类Class对象,也可以用getClass()获得.可以利用此Class对象进行一些反射特性的操作.hashCode public int hashCode() hashCode是jdk根据对象的地址或者字符串或者数字算出来的int类型的数值

Tomcat Server Configuration Automation Reinforcement(undone)

目录 0. 引言 1. 黑客针对WEB Server会有那些攻击面 2. 针对Tomcat Server可以做的安全加固 3. Managing Security Realms with JMX 4. 实现对TOMCAT配置信息的动态修改(hot dynamic edit) 5. Tomcat后台manager页面禁用 0. 引言 WEB容器(WEB Server)是运行在操作系统上的一个应用级软件,对服务器的配置(config文件)进行加固处理是防御WEB相关漏洞的一个有效的手段.对于实现WE