ClassNotFoundException when mapping com.google.protobuf.Timestamp
See original GitHub issueWhats your runtime?
- Dozer version: 6.1.0
- OS version: osx 10.12.6
- JDK version: 1.8.144
Whats the problem?
Steps to reproduce:
- Create new dozer mapper
- (Optional) Create one custom converter with LocalDate and com.google.protobuf.Timestamp
- Call : mapper.map(new LocalDate(), Timestamp.class)
Dozer is trying to load class: com.google.protobuf.TimestampProto.Timestamp, which doesn’t exist in proto3
ProtoUtils.java@156
return MappingUtils.loadClass(StringUtils.join( getFullyQualifiedClassName(descriptor.getMessageType().getFile().getOptions(), descriptor.getMessageType().getName()), '.'), beanContainer);
Method:
private static String[] getFullyQualifiedClassName(DescriptorProtos.FileOptions options, String name) { return new String[] { options.getJavaPackage(), options.getJavaOuterClassname(), name}; }
Observed Results:
Caused by: org.dozer.MappingException: java.lang.ClassNotFoundException: com.google.protobuf.TimestampProto.Timestamp from [Module "xxx:main" from local module loader @768b970c (finder: local module finder @5a4041cc (roots: /apps/jboss/modules,/apps/jboss/modules/system/layers/base))] at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:82) [dozer-core-6.1.0.jar:6.1.0] at org.dozer.util.DefaultClassLoader.loadClass(DefaultClassLoader.java:46) [dozer-core-6.1.0.jar:6.1.0] at org.dozer.util.MappingUtils.loadClass(MappingUtils.java:223) [dozer-core-6.1.0.jar:6.1.0] at com.github.dozermapper.protobuf.util.ProtoUtils.getJavaClassIgnoreRepeated(ProtoUtils.java:156) [dozer-proto-6.1.0.jar:] at com.github.dozermapper.protobuf.util.ProtoUtils.getJavaClass(ProtoUtils.java:125) [dozer-proto-6.1.0.jar:] at com.github.dozermapper.protobuf.propertydescriptor.ProtoFieldPropertyDescriptor.getPropertyType(ProtoFieldPropertyDescriptor.java:77) [dozer-proto-6.1.0.jar:] at org.dozer.fieldmap.FieldMap.getSrcFieldType(FieldMap.java:131) [dozer-core-6.1.0.jar:6.1.0] at org.dozer.loader.MappingsParser.processMappings(MappingsParser.java:113) [dozer-core-6.1.0.jar:6.1.0] at org.dozer.loader.CustomMappingsLoader.load(CustomMappingsLoader.java:64) [dozer-core-6.1.0.jar:6.1.0] at org.dozer.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:326) [dozer-core-6.1.0.jar:6.1.0] at org.dozer.DozerBeanMapper.initMappings(DozerBeanMapper.java:443) [dozer-core-6.1.0.jar:6.1.0] at org.dozer.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:305) [dozer-core-6.1.0.jar:6.1.0] at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:214) [dozer-core-6.1.0.jar:6.1.0]
Expected Results:
To not load TimestampProto.Timestamp but use Timestamp. Dozer should be able to handle 2 cases, one where the class XXXProto encapsulates XXX, and other case when XXX and XXXProto are two files like Timestamp example.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (3 by maintainers)
Top GitHub Comments
Yes it is pretty obvious what should be done, I’m looking at it right now
@jbq ; do you understand what we’d need to do for: java_multiple_files ?