[jboss-user] [Management, JMX/JBoss] - How do I remotely access an mbean attribute value?
rcolaco
do-not-reply at jboss.com
Wed Sep 19 20:02:28 EDT 2007
Hi there:
I have two mbeans that are deployed on my JBoss 4.0.5 GA server.
One is Tomcat's HttpRequest mbean (THM) and one is my Application mbean (AM).
For AM, I am able to remotely access an mbean attribute value using the following code snippet:
final Hashtable<String, String> env = new Hashtable<String, String>();
| final String factory = "org.jnp.interfaces.NamingContextFactory";
| env.put(Context.INITIAL_CONTEXT_FACTORY, factory);
|
| ObjectName on = new ObjectName("jboss:service=MyAppMbean");
| final String url = "jnp://myserver:1099";
| env.put(Context.PROVIDER_URL, url);
| Context ctx = new InitialContext(env);
| MBeanServerConnection connection = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
| System.out.println(connection.getAttribute(on, "Summary"));
| ctx.close();
However, when I attempt to connect to the Tomcat Mbean...
e.g.
ObjectName = jboss.web:name=HttpRequest0,type=RequestProcessor,worker=http-0.0.0.0-8080
I am trying to retrieve attribute values for attributes...
- requestProcessingTime
- remoteAddr
- maxRequestUri
However, my call using...
connection.getAttribute(on, "requestProcessingTime")
... fails with the following error:
Exception in thread "Main Thread" javax.management.AttributeNotFoundException: not found: requestProcessingTime
at org.jboss.mx.server.AbstractMBeanInvoker.getAttribute(AbstractMBeanInvoker.java:335)
at org.jboss.mx.server.MBeanServerImpl.getAttribute(MBeanServerImpl.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Any recommendations on how I can get the value of a specific attribute for the HttpRequest mbeans?
Also note that I include jbossall-client.jar in my remote client application's runtime classpath that I use to connect to my server.
Thanks in advance.
- Rohit
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086391#4086391
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086391
More information about the jboss-user
mailing list