2 Replies Latest reply on Jan 8, 2002 1:25 AM by dim

    ObjectMessage - Class definition

    dim

      Hi,

      This is probably a fairly simple query on ObjectMessages and MDBs, but its got me stumped atm...

      ok, I have a simple MDB, that atm does nothing (apart from have ClassCast issues). It receives an ObjectMessage, the object class is in a jar, in lib/ext. Yet when I try to cast the object in the message, I get a ClassCastException. To dig further, I've put the following code in my MDB:

       System.out.println("o = " + o);
       System.out.println("o.getClass().getName() = " + o.getClass().getName());
       if (o instanceof DataObject)
       handleDataObject((DataObject) o);
       else
       System.out.println("o not DataObject.");
      

      but the output I get is:
       [exec] o = [Lorg.openadaptor.dataobjects.DataObject;@9e5ee4a
       [exec] o.getClass().getName() = [Lorg.openadaptor.dataobjects.DataObject;
       [exec] o not DataObject.
      

      Which is really confusing me. I've tried all sorts of stupid things, like including the jar containing DataObject inside the deployed jar, but that didn't get me anywhere either.

      I fear that I've left something astray, and haven't found it... if someone could point me in the right direction I'd be very greatful (o:

      cheers
      dim

        • 1. Re: ObjectMessage - Class definition
          dim

          further to this, I've added the following code:

           // classes
           System.out.println("DataObject.class: " + DataObject.class);
           System.out.println("Object.class : " + o.getClass());
          
           // class hashcodes
           System.out.println("DataObject hashcode: " + DataObject.class.hashCode());
           System.out.println("Object hashcode : " + o.getClass().hashCode());
          
           // classloaders
           System.out.println("DataObject classloader: " + DataObject.class.getClassLoader());
           System.out.println("Object classloader : " + o.getClass().getClassLoader());
          
           // classloader hashcodes
           System.out.println("DataObject classloader hashcode: " + DataObject.class.getClassLoader().hashCode());
           System.out.println("Object classloader hashcode : " + o.getClass().getClassLoader().hashCode());
          
           System.out.println("class.equals(class)=" + DataObject.class.equals(o.getClass()));
          

          and get the following output:
           [exec] DataObject.class: interface org.openadaptor.dataobjects.DataObject
           [exec] Object.class : class [Lorg.openadaptor.dataobjects.DataObject;
           [exec] DataObject hashcode: 1068196008
           [exec] Object hashcode : 883548328
           [exec] DataObject classloader: javax.management.loading.MLet@4b57a0ad
           [exec] Object classloader : javax.management.loading.MLet@4b57a0ad
           [exec] DataObject classloader hashcode: 1264033965
           [exec] Object classloader hashcode : 1264033965
           [exec] class.equals(class)=false
          

          now I dont know if maybe I'm completely misunderstanding things, but to me, it looks like the classloader is loading two instances of the class - one an interface, and one an actual class. I thought this wasn't possible... anyone have any ideas?

          tia
          dim

          • 2. Re: ObjectMessage - Class definition
            dim

            Just in case anyone comes back to this... the answer is of course obvious. One is DataObject[] and one is DataObject.

            It was one of those late light, end of year things :)

            cheers
            dim