Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5994

java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.reflect.TypeVariable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.11
    • 3.1.9
    • JAXB Databinding
    • None
    • Wildfly 8.1.0.Final, JDK: 1.8.0_20-b26 64bit

    • Advanced

    Description

      java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.reflect.TypeVariable
      at org.apache.cxf.jaxb.JAXBContextInitializer.addType(JAXBContextInitializer.java:251) [cxf-rt-databinding-jaxb-2.7.11.jar:2.7.11]

      Happens when the type is a GenericArrayType: then the code assumes that the component in the array type is either a class or a TypeVariable, and the cast into TypeVariable fails.
      During debug sessions, I can see that the actual type is an array of a subtype of ParameterizedType, and obviously the code does not permit this.

      The data types were generated with Maven and cxf-codegen-plugin. The XSD is from Microsoft Exchange EWS (Exchange Web Service, 2006). The problematic type is: com.microsoft.schemas.exchange.services._2006.messages.ResponseMessageType[]

      This is blocking as any webservice which uses the data types of EWS fails if called with the standard JAXWS stack in Wildfly 8.1.0.Final.

      For the fix: maybe copying lines 234 to 243 into line 250 may be almost enough (simply add an else-if for ParameterizedType arrays as above, but adapt a little for arrays):

      else if (cls instanceof ParameterizedType) {
      final ParameterizedType parameterizedType = (ParameterizedType)cls;
      addType(parameterizedType.getRawType());
      if (!parameterizedType.getRawType().equals(Enum.class)) {
      for (Type t2 : parameterizedType.getActualTypeArguments()) {
      if (shouldTypeBeAdded(t2, parameterizedType))

      { addType(t2); }

      } }

      Thanks

      Attachments

        Activity

          People

            Unassigned Unassigned
            nickywhite Yannick Loth
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified