2 Replies Latest reply on May 18, 2007 5:09 AM by ulmer

    MBeans: Unable to cast the returned object instance

    ulmer

      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:


      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.