3 Replies Latest reply on Jun 27, 2010 1:45 AM by bluestix

    problem with blazeds & inheritance

    CatPoweredTM

      I'm having trouble mapping to my java classes

       

      I have, on the java side

      public abstract class Base implements Serializable, Externalizable {

      .. some member fields


      public void readExternal(...)

      {
           some assignment to the member fields

      }


      public void writeExternal(...)

      {

           write out the member fields

      }

      }

       

       

      Then the actual sub class

      public class Derived extends Base {

      ... some more member fields

       

      @Override

      public void readExternal(...)

      {

           super.readExternal

           handle the extra fields

      }


      similar thing for the writeExternal

       

       

      On the AS3 side, I have

      [Bindable]

      [RemoteClass(alias="thatBaseClass")]

      public class Base implements IExternalizable

      {

           the members from java's base class

           read/writeExternal that handle those fields

      }

       

      then for the subclass

      [Bindable]

      [RemoteClass(alias="thatDerivedClass")]

      public class Derived extends Base

      {

           the same additional members as the java side
           override the read/WriteExternal methods to include the additional members

      }

       

       

       

       

      Now, when I run the following:

      java:

      public Derived test() {

           return new Derived();

      }

       

      AS3:

      setup remote object

      setup listeners

      remoteObject.test()

       

      I get the following error on the AS3 side

      [FaultEvent fault=[RPC Fault faultString="Didn't receive an acknowledge message" faultCode="Server.Acknowledge.Failed" faultDetail="Was expecting mx.messaging.messages.AcknowledgeMessage, but received null"] messageId="344B0ECA-F06A-5549-06E7-461D547A1727" type="fault" bubbles=false cancelable=true eventPhase=2]

       

      in the blazeds log, I see

        (Message #3 targetURI=/6/onResult, responseURI=)

          (Externalizable Object #0 'DSK')

            (Externalizable Object #1 'Derived')

              null

        • 1. Re: problem with blazeds & inheritance
          bluestix

          I am having the same problem.

           

          Did you ever figure this out?

           

           

           

          At first I was just using the default serialization but for some reason most of the properties of my classes were not getting sent across the wire.

           

          The classes were getting set to the correct type though.

           

           

          So then I implemented IExternalizable on both Flex and Java side which cause even weirder problems.

           

           

          Now the remoting packet gets totally mangled.

           

          I am using Charles and it shows the actual object in the request as being null and then random other properties of the request like the headers are getting set to the values from the DTO I am trying to send across the wire.

           

           

          I can't figure out what is wrong with it.

           

           

          Been stuck for like a week.

           

           

          I made a simple test class and it works fine using the default serialization.

          • 2. Re: problem with blazeds & inheritance
            CatPoweredTM Level 1

            ya this was due to my stupidity...

             

            there were two methods: write(int x) and writeInt(int x). The first one

            writes only a byte from x whereas the later one writes the entire int. My

            problem was that I didn't realize the type and did write(int x) on one side

            and did readInt() on the other side. The serializer ran out of bytes to read

            and had that null pointer.

             

            as for your problem, I'm not really sure =/

            • 3. Re: problem with blazeds & inheritance
              bluestix Level 1

              Turns out it was my stupidity too.

               

               

              I was using readObject and writeObject for long values instead of readLong/writeLong on the Java side and readDouble/writeDouble on the flex side.