[jboss-user] [Management, JMX/JBoss] - MBeans: Unable to cast the returned object instance

Ulmer do-not-reply at jboss.com
Tue May 8 10:47:48 EDT 2007


Hi all,

executing a mbean method with a custom return type i can't cast the returned object instance to the appropriate data type.

ClassCastException:
anonymous wrote : 
  | java.lang.ClassCastException: mypackage.MyDto cannot be cast to mypackage.MyDto

MBean:

  | public interface MyMBean extends org.jboss.system.ServiceMBean {
  | ...
  |    public MyDto holeMyDto(String test) throws Exception;
  | ...
  | }
  | 

Dto (Data Transfer object)

  | public class MyDto implements Serializable {
  |   private static final long serialVersionUID = 3679919263323839707L;
  | ...
  | }
  | 


Client (deployed in a separate .war)

  |      InitialContext ic = new InitialContext();
  |      String rmiadaptername = "jmx/invoker/RMIAdaptor";
  |     MBeanServerConnection mbsc = (MBeanServerConnection) ic.lookup(rmiadaptername);
  |     ObjectName objectName = new ObjectName(objectNameString);
  |     Object[] oa = { "P"};
  |     String[] sa = { "java.lang.String"};
  |     Object object = mbsc.invoke(objectName, "holeMyDto", oa, sa);
  |     DataPoolInfo result = (DataPoolInfo) object; // here comes the Exception
  | 

The execution from the jmx-console works fine. Please help.
Jboss 4.0.5 GA; Jdk 6.

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

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



More information about the jboss-user mailing list