IBM Support

IV79921: USING MARSHALLER ON XJC GENERATED CLASSES CAUSES JAVA.LANG.CLASS CASTEXCEPTION: JAVA.LANG.LONG CANNOT BE CAST TO JAVA.LANG.STR

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Error Message: java.lang.ClassCastException: java.lang.Long
    cannot be cast to java.lang.String
    .
    Stack Trace: N/A
    .
    

Local fix

  • Any of the following  workarounds can be used to avoid the
    error:
    - Remove the annotation from the generated classes.
    OR
    - Have an external binding file
    <jaxb:bindings
    node="//xs:element<OSB>@type='YourSimpleType'<CSB>">
    <annox:annotate
    target="field">@javax.xml.bind.annotation.XmlSchemaType(name="Yo
    urSimpleType")</annox:annotate> </jaxb:bindings>
    OR
    - Change the name of XMLSchemaType to your simple Type.
    

Problem summary

  • In JAXB 2.2.7 a  fix has been introduced  in JAXB to impose
    restrictions on simple type like Enum which generates an extra
    annotation @XmlSchemaType  which declares the type of the Simple
    type.However this was not handling a collection like List
    holding a simpleType  of primitive (other than String).In this
    case XJC is generating the annotation @XmlSchemaType
    (type="anySimpleType")  on the List element.
    During runtime, marshaller is parsing the annotation and trying
    to cast the List element to String and resulting in the
    ClassCastException
    

Problem conclusion

  • The JAX has been updated to validate the type before generating
    the annotation. No annotation will be generated for primitive
    types.
    This issue is handled in Oracle JDK through
    https://java.net/jira/browse/JAXB-986
    .
    This APAR will be fixed in the following Java Releases:
       8    SR2 FP10  (8.0.2.10)
    .
    Contact your IBM Product's Service Team for these Service
    Refreshes and Fix Packs.
    For those running stand-alone, information about the available
    Service Refreshes and Fix Packs can be found at:
               https://www.ibm.com/developerworks/java/jdk/
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV79921

  • Reported component name

    JAVA CLASS LIBS

  • Reported component ID

    620700130

  • Reported release

    800

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2015-12-22

  • Closed date

    2016-01-06

  • Last modified date

    2016-01-06

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    JAVA CLASS LIBS

  • Fixed component ID

    620700130

Applicable component levels

  • R800 PSY

       UP

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"8.0","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
21 February 2022