Hi All,
jboss3.2.3
I made a simple MBean, deployed it properly and could invoke the say(String greeting) method on jmx-console, but I got the exception when I invoked the say(String greeting) method with my client application.
my MBean source code:
package com.cxtg;
import org.jboss.system.ServiceMBeanSupport;
public class Hello extends ServiceMBeanSupport implements HelloMBean {
public void say(String greeting) {
System.out.println(greeting);
}
}
package com.cxtg;
import org.jboss.system.ServiceMBean;
public interface HelloMBean extends ServiceMBean {
public void say(String greeting);
}
jboss-service.xml
<server>
<mbean code="com.cxtg.Hello" name="jboss:service=Hello" interface="com.cxtg.HelloMBean"/>
</server>
my client application source code
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
import com.cxtg.Hello;
public class MainApp {
public static void main(String[] args) {
try{
MBeanServer server=MBeanServerFactory.createMBeanServer();
ObjectName name=new ObjectName("jboss:service=Hello");
server.registerMBean(new Hello(), name);
String[] sig={"String"};
Object[] opArgs={new String("Hi")};
server.invoke(name, "say", opArgs, sig);
}catch(Exception e){
e.printStackTrace();
}
}
}
Exception
ReflectionException: null
Cause: java.lang.NoSuchMethodException: Unable to locate MBean operation for: say(String)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:288)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
at MainApp.main(MainApp.java:48)
What goes wrong??? please help.
Kalmn Cheung