question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClassNotFoundException when mapping com.google.protobuf.Timestamp

See original GitHub issue

Whats your runtime?

  • Dozer version: 6.1.0
  • OS version: osx 10.12.6
  • JDK version: 1.8.144

Whats the problem?

Steps to reproduce:

  1. Create new dozer mapper
  2. (Optional) Create one custom converter with LocalDate and com.google.protobuf.Timestamp
  3. 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:closed
  • Created 6 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jbqcommented, Oct 23, 2017

Yes it is pretty obvious what should be done, I’m looking at it right now

0reactions
garethahealycommented, Oct 18, 2017

@jbq ; do you understand what we’d need to do for: java_multiple_files ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

NoSuchMethodException and NoClassDefFoundError in grpc ...
In this case you will find that com.google.api.grpc:proto-google-common-protos:0.1.9 is depending on com.google.protobuf:protobuf-java:3.2.0 ...
Read more >
getquill/quill - Gitter
If you create mapped using java long like below ... Long, com.google.protobuf.timestamp. ... ClassNotFoundException: jdk.internal.misc.Unsafe at java.net.
Read more >
com.google.protobuf Class Hierarchy
Package Hierarchies: All Packages. Class Hierarchy. java.lang.Object. java.util.AbstractMap<K,V> (implements java.util.
Read more >
Protobuf Schema Serializer and Deserializer
For example, if the main schema references “ google/protobuf/timestamp.proto ” ... in the table under JSON Mapping in the Protocol Buffers Developer Guide....
Read more >
java.lang.ClassNotFoundException: com.google.protobuf ... - Re
lang.ClassNotFoundException: com.google.protobuf.Message I do. I tried with protobuf-java-2.4.0a.jar that ships with HBase 0.94, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found