When trying to map a field with nested generic types like List<List<String>> I get a ClassCastException:
Exception in thread "main" java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
at org.dozer.util.ReflectionUtils.determineGenericsType(ReflectionUtils.java:364)
at org.dozer.util.ReflectionUtils.determineGenericsType(ReflectionUtils.java:352)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.genericType(GetterSetterPropertyDescriptor.java:335)
at org.dozer.fieldmap.FieldMap.getGenericType(FieldMap.java:145)
at org.dozer.MappingProcessor.mapCollection(MappingProcessor.java:493)
at org.dozer.MappingProcessor.mapOrRecurseObject(MappingProcessor.java:422)
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:330)
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:276)
at org.dozer.MappingProcessor.map(MappingProcessor.java:245)
at org.dozer.MappingProcessor.map(MappingProcessor.java:187)
at org.dozer.MappingProcessor.map(MappingProcessor.java:124)
at org.dozer.MappingProcessor.map(MappingProcessor.java:119)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:111)
at DozerTest.main(DozerTest.java:26)
See example in the attached Java file.
Example for ClassCastException when mapping nested generic types like List<List<String>>
Hi Martin,
It looks a quite old thread, but did you tried to specify a hint to the destination object a List?
<b-hint>java.util.List</b-hint>
Regards.
Sorry, it's too long ago. I can't remember if and how I fixed the problem.