[jboss-user] [Management, JMX/JBoss] - Re: How to write Jython scripts to communicate with MBeans

maxdiconoclast do-not-reply at jboss.com
Wed Feb 4 06:34:43 EST 2009

I seemed to have found the answer, what I was doing wrong was that, the RMI connxn was not being initialized correctly to the server.
Below is a small snippet which worked for me.

from java.util import Properties
from java.lang import System
from javax.naming import InitialContext
from javax.management import NotificationListener,ObjectName,MBeanInfo,MBeanAttributeInfo

class ClientListener(NotificationListener):
	print "Will it work :("
	props = Properties(System.getProperties())
	props.put("java.naming.provider.url", "jnp://localhost:1099")
	props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory")
	ctx = InitialContext(props)
	adapterName = "jmx/invoker/RMIAdaptor"
	server = ctx.lookup(adapterName)
	name = ObjectName("jboss:service=JNDIView")
	info = server.getMBeanInfo(name)
	print "JNDIView Class: " + info.getClassName()
	print "      "
	aValue = server.getAttribute(name,"HANamingService")
	print "Value of HANamingService is::: " + aValue
	print "It worked Bye Bye! :)"


This made the communication with the MBean server and fetched me a dummy value of the configured MBean.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4206889#4206889

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4206889

More information about the jboss-user mailing list