[Management, JMX/JBoss] - How do I remotely access an mbean attribute value?
by rcolaco
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
18 years, 10 months
[JBoss Seam] - DVD Store sample - returns "success".
by gersonk
I'm trying to understand the 'DVD Store' sample that comes with seam distribution. The EditCustomerAction.saveUser() could return the "success" string, but I can't find its reference in the pages.xml. How does Seam know which page it should forward to?
| public String saveUser() {
| if (!isValidNamePassword()) {
| facesMessages.add("User name #{customer.userName} is not unique");
| return null;
| }
|
| try {
| em.persist(customer);
| sessionContext.set("currentUser", customer);
| Actor.instance().setId(customer.getUserName());
|
| identity.setUsername(customer.getUserName());
| identity.setPassword(customer.getPassword());
| identity.login();
|
| facesMessages.addFromResourceBundle("createCustomerSuccess");
| return "success";
| } catch (InvalidStateException e) {
| InvalidValue[] vals = e.getInvalidValues();
| for (InvalidValue val: vals) {
| facesMessages.add(val);
| }
|
| return null;
| } catch (RuntimeException e) {
| ctx.setRollbackOnly();
|
| facesMessages.addFromResourceBundle("createCustomerError");
|
| return null;
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086389#4086389
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086389
18 years, 10 months