Reputation: 2310
The exception I am getting is:
java.lang.NullPointerException
at org.dozer.MappingProcessor.getClassMap(MappingProcessor.java:1034)
at org.dozer.MappingProcessor.map(MappingProcessor.java:162)
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 com.shiladit.CategoryResource.get(CategoryResource.java:120)
I recently upgraded to dozerBeanMapper 5.3.2.
I have defined custom mappings through XML. Where might I be going wrong?
EDIT: I saw line 1034 in MappingProcessor here, where I assume classMappings is null, which probably means the custom XML mappings defined are not getting picked up.
Upvotes: 1
Views: 2692
Reputation: 511
If you instantiate the Mapper like this:
Mapper mapper = new DozerBeanMapper();
DestinationObject destObject =
mapper.map(sourceObject, DestinationObject.class);
you don't need the file with the mappings. If you instantiate mapper using the production way (dozer documentation ) you need the dozerBeanMapping.xml file with the mapping.
Mapper mapper = DozerBeanMapperSingletonWrapper.getInstance();
DestinationObject destObject =
mapper.map(sourceObject, DestinationObject.class);
Otherwise you will receive the exception that you posted. I have seen it debugging the source code of Dozer lib.
Are you instantiating Mapper using DozerBeanMapperSingletonWrapper ?
hope it helps
Upvotes: 0