I have create a custom JavaBean I want to return from my MBean method. The following is the custom JavaBean:
package org.text.jmx;
public class Person {
private firstName;
private lastName;
public Person(){
}
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
The MBean interface is the following:
package org.text.jmx;
public interface TestJmxMBean {
public Person getPerson();
public void setPerson(String firstName, String lastName);
}
The class the implements the MBean:
package org.text.jmx;
public class TestJmx implements TestJmxMBean {
private Person person = new Person();
public Person getPerson() {
return person;
}
public void setPerson(String firstName, String lastName) {
person.setFirstName(firstName);
person.setLastName(lastName);
}
}
I create a server application that registers the above MBean, which is successful. I create a client application which successfully connects to the server application via JMX, but when I call the testJmx.getPerson() method from the client application is receive an error that it can't return the Person object. What am I doing wrong? It works fine is I just define the return type as as String or String[] from the TestJmx.getPerson().