JiBX
  1. JiBX
  2. JIBX-29

ClassCast Exception when unmarshalling

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-beta3b
    • Fix Version/s: 1.0-beta3c
    • Component/s: core
    • Labels:
      None
    • Environment:
      Windows 2000 server, JDK 1.4.2
    • Number of attachments :
      0

      Description

      There is the stack trace I obtained when unmarshalling a JiBX generated XML document:
      java.lang.ClassCastException
      at com.actualis.sage.DocumentVte.JiBX_xml_bindings_unmarshal_2_0(DocumentVte.java)
      at com.actualis.sage.JiBX_xml_bindingsDocumentVte_access.unmarshal()
      at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2568)
      at com.actualis.sage.JiBX_MungeAdapter.JiBX_xml_bindings_unmarshal_1_0()
      at com.actualis.sage.DocumentsVte.JiBX_xml_bindings_unmarshal_3_1(DocumentsVte.java)
      at com.actualis.sage.JiBX_xml_bindingsDocumentsVte_access.unmarshal()
      at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2568)
      at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2736)
      at com.actualis.ExportManager.readZipVector(ExportManager.java:162)
      at com.actualis.SageDB.importFromFile(SageDB.java:144)

      And there an excerpt of the source code:
      public String DO_Piece;
      public Timestamp DO_Date;
      public String DO_Ref = "";
      public Timestamp DO_DateLivr;
      public String DO_Tiers;
      public int DE_No = 1;
      public long LI_No = 1;
      public long lieu_livraison_tmp = -1;
      public long lieu_enlevement = -1;
      public int DO_Period = 1;
      public int DO_Devise = 0;
      public static final String[] DEVISES =

      { "EUR", "FRF" }

      ;
      public double DO_Cours;
      public String CT_NumPayeur;
      public int DO_Expedit;
      public int DO_Condition = 1;
      public int DO_Langue = 1;
      public int RE_No = 0;
      public String DO_Coord01 = "";
      public String DO_Coord02 = "";
      public String DO_Coord03 = "";
      public String DO_Coord04 = "";
      public String affaire = "";
      public int DO_Tarif;
      public int DO_Regime = 21;
      public int DO_Transaction = 11;
      public int DO_Colisage = 1;
      public int DO_TypeColis = 1;
      public int nb_factures = 1;
      public boolean UnSeul_BL_Fac = false;
      public double DO_TxEscompte = 0;
      public double ecart_valorisation = 0;
      public int N_CatCompta = 1;
      public boolean frais_ventile = false;
      public int DO_Statut = 0;
      public String compte_general = "";
      public boolean DO_Cloture = false;
      public String id_cmd_inet = "";
      public String ip_address = null;

      at com.actualis.sage.SageLANGateway.importFiles(SageLANGateway.java:118)
      at com.actualis.sage.SageLANGateway.exec_imports(SageLANGateway.java:90)
      at com.actualis.sage.SageLANGateway.start(SageLANGateway.java:50)
      at com.actualis.LANGateway.exec(LANGateway.java:132)
      at com.actualis.sage.SageLANGateway.main(SageLANGateway.java:132)

      Here is the output of the compiler on my class:
      [bind] mapping class com.actualis.sage.DocumentsVte to element DocumentsVteList
      [bind] element wrapper DocumentsVteList
      [bind] object binding for com.actualis.sage.DocumentsVte
      [bind] structure ordered
      [bind] mapping reference to com.actualis.ActualisBOFlags using optional property m_flags (com.actualis.ActualisBOFlags)
      [bind] optional structure wrapper property m_list (java.util.ArrayList) (load marshal)
      [bind] element wrapper DocumentsVte optional structure object
      [bind] component property m_list (java.util.ArrayList) (pass-through marshal)
      [bind] object binding for java.util.ArrayList
      [bind] collection ordered
      [bind] direct generic reference

      and

      [bind] mapping class com.actualis.sage.DocumentVte to element DocumentVte
      [bind] element wrapper DocumentVte
      [bind] object binding for com.actualis.sage.DocumentVte
      [bind] structure ordered
      [bind] element sync_state from optional property sync_state (int)
      [bind] element UID from optional property UID (long)
      [bind] element DO_Type from optional property DO_Type (int)
      [bind] element DO_Piece from optional property DO_Piece (java.lang.String)
      [bind] element DO_Date from optional property DO_Date (java.sql.Timestamp)
      [bind] element DO_Ref from optional property DO_Ref (java.lang.String)
      [bind] element DO_DateLivr from optional property DO_DateLivr (java.sql.Timestamp)
      [bind] element DO_Tiers from optional property DO_Tiers (java.lang.String)
      [bind] element DE_No from optional property DE_No (int)
      [bind] element LI_No from optional property LI_No (long)
      [bind] element lieu_livraison_tmp from optional property lieu_livraison_tmp (long)
      [bind] element lieu_enlevement from optional property lieu_enlevement (long)
      [bind] element DO_Period from optional property DO_Period (int)
      [bind] element DO_Devise from optional property DO_Devise (int)
      [bind] element DO_Cours from optional property DO_Cours (double)
      [bind] element CT_NumPayeur from optional property CT_NumPayeur (java.lang.String)
      [bind] element DO_Expedit from optional property DO_Expedit (int)
      [bind] element DO_Condition from optional property DO_Condition (int)
      [bind] element DO_Langue from optional property DO_Langue (int)
      [bind] element RE_No from optional property RE_No (int)
      [bind] element DO_Coord01 from optional property DO_Coord01 (java.lang.String)
      [bind] element DO_Coord02 from optional property DO_Coord02 (java.lang.String)
      [bind] element DO_Coord03 from optional property DO_Coord03 (java.lang.String)
      [bind] element DO_Coord04 from optional property DO_Coord04 (java.lang.String)
      [bind] element affaire from optional property affaire (java.lang.String)
      [bind] element DO_Tarif from optional property DO_Tarif (int)
      [bind] element DO_Regime from optional property DO_Regime (int)
      [bind] element DO_Transaction from optional property DO_Transaction (int)
      [bind] element DO_Colisage from optional property DO_Colisage (int)
      [bind] element DO_TypeColis from optional property DO_TypeColis (int)
      [bind] element nb_factures from optional property nb_factures (int)
      [bind] element UnSeul_BL_Fac from optional property UnSeul_BL_Fac (boolean)
      [bind] element DO_TxEscompte from optional property DO_TxEscompte (double)
      [bind] element ecart_valorisation from optional property ecart_valorisation (double)
      [bind] element N_CatCompta from optional property N_CatCompta (int)
      [bind] element frais_ventile from optional property frais_ventile (boolean)
      [bind] element DO_Statut from optional property DO_Statut (int)
      [bind] element compte_general from optional property compte_general (java.lang.String)
      [bind] element DO_Cloture from optional property DO_Cloture (boolean)
      [bind] element id_cmd_inet from optional property id_cmd_inet (java.lang.String)

        Activity

        Hide
        Henri Dupre added a comment -

        A custom serializer for the timestamp format solved this issue.
        The problem is that java.sql.Timestamp inherits of java.util.Date.

        My guess of the issue is that jibx compiler checks if a field is "instanceOf Date" and uses its internal date serializers for it. But on the unmarshalling of any type that extends Date, there will be a ClassCastException. The compiler should check for exact types instead.

        Show
        Henri Dupre added a comment - A custom serializer for the timestamp format solved this issue. The problem is that java.sql.Timestamp inherits of java.util.Date. My guess of the issue is that jibx compiler checks if a field is "instanceOf Date" and uses its internal date serializers for it. But on the unmarshalling of any type that extends Date, there will be a ClassCastException. The compiler should check for exact types instead.
        Hide
        Dennis Sosnoski added a comment -

        Confirmed the problem diagnosis and corrected it. Also added a java.sql.Date serializer/deserializer to the standard set. The other java.sql time-related classes are a little more painful to handle, though, so are skipped for now (and can be handled with custom serializer/deserializers in any case).

        Show
        Dennis Sosnoski added a comment - Confirmed the problem diagnosis and corrected it. Also added a java.sql.Date serializer/deserializer to the standard set. The other java.sql time-related classes are a little more painful to handle, though, so are skipped for now (and can be handled with custom serializer/deserializers in any case).

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Henri Dupre
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: