Go Back

"Incompatible classes" error when accessing structure data passed as ArrayList to Synergy with xfServerPlus from xfNetLink client

Article Number: 2224
First Published:
Modified:
Recent Activity:
Views: 38
OS: Windows, Unix, OpenVMS
Product: Synergy DBL, xfServerPlus, xfNetLink .NET, xfNetLink Java

You may see an "incompatible classes" ($ERR_INCPTCLS) error when returning an ArrayList of structures to xfServerPlus from xfNetLink Java or xfNetLink .NET. This error occurs because the elements of the collection cannot be cast to the data type of the loop variable.


When a structure is defined in the Repository for use with xfServerPlus, the structure becomes a class named with the structure name and, by default, each of the structure’s fields becomes a property of that class. This structure may be populated and used to pass data between client and server. If the parameter is defined as an ArrayList in the SMC, it is passed to the Synergy server from an xfNetLink client as an ArrayList of boxed alpha elements.


On the Synergy side, use a FOREACH loop to extract the data from the incoming ArrayList. In your Synergy code, declare the parameter as @System.Collections.Arraylist and declare the FOREACH loop counter variable as a boxed alpha (@a). As the FOREACH loop iterates through the ArrayList, use these variables to extract the data.


For example,


import System.Collections
.INCLUDE "MyStructure" REPOSITORY,structure,end
mySub
   ; Inbound ArrayList argument populated on the client and sent to the Synergy server
   req in myList   ,@ArrayList
   .
   .
   .
record
   structfld       ,MyStructure
   myCounter       ,@a      ;boxed alpha
   .
   .
   .
   foreach myCounter in myList
      begin
        structfld = (a)myCounter ;Cast boxed alpha back to alpha when assigning
                                 ; into structfield
     .
      .
      .
      end

 



THE INFORMATION PROVIDED TO YOU IN THIS SERVICE IS FOR YOUR USE ONLY. THE INFORMATION MAY HAVE BEEN DEVELOPED INTERNALLY BY SYNERGEX OR BY EXTERNAL SOURCES. SYNERGEX MAKES NO WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS INFORMATION, INCLUDING THE WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SYNERGEX BE LIABLE FOR ANY DAMAGES OR LOSSES INCURRED BY YOU IN USING OR RELYING ON THIS INFORMATION, INCLUDING WITHOUT LIMITATION GENERAL DAMAGES, DIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES, OR LOSS OF PROFITS, EVEN IF SYNERGEX HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Please log in to comment on this article.