Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.7.11
-
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))
} }
Thanks