I’m using Hybris and Orika.
I have a NullpointerException when converting WsDto to Data.
This is an exception:
Caused by: java.lang.NullPointerException at ma.glasnost.orika.generated.Orika_OrderWsDTO_OrderData_Mapper15385839217600$109.mapBtoA(Orika_OrderWsDTO_OrderData_Mapper15385839217600$109.java) at ma.glasnost.orika.impl.ReversedMapper.mapAtoB(ReversedMapper.java:65) at ma.glasnost.orika.impl.mapping.strategy.UseCustomMapperStrategy.map(UseCustomMapperStrategy.java:77) at ma.glasnost.orika.impl.DefaultBoundMapperFacade.mapReverse(DefaultBoundMapperFacade.java:152) at ma.glasnost.orika.generated.Orika_ReturnRequestWsDTO_ReturnRequestData_Mapper15384183367700$80.mapBtoA(Orika_ReturnRequestWsDTO_ReturnRequestData_Mapper15384183367700$80.java) at ma.glasnost.orika.impl.ReversedMapper.mapAtoB(ReversedMapper.java:65) at ma.glasnost.orika.impl.mapping.strategy.UseCustomMapperStrategy.map(UseCustomMapperStrategy.java:77) at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:671) ... 146 more
The issue – it happens in generated class so it’s very hard to debug.
I’ve also tried to enable code generation for Orika to check classes, but for some reason, the configuration doesn’t apply. I’ve done it this way:
tomcat.debugjavaoptions= -Dma.glasnost.orika.writeSourceFiles=true -Dma.glasnost.orika.writeClassFiles=true
My questions are:
- Could you help me to enable this code generation for further debugging?
- Could you point out why this exception could happen, since it’s not clear at the moment?
The exception in debug mode doesn’t provide data to me.
Update
Found out that issue comes from mapping for fields, it’s done in XML this way:
<bean parent="fieldMapper" id="cisOrderWsDTOFieldMapper"> <property name="sourceClass" value="Data" /> <property name="destClass" value="WsDto" /> <property name="fieldMapping"> <map> <entry key="price.discount" value="discount"/> </map> </property>
Advertisement
Answer
The issue was because of the mapping configuration:
<bean parent="fieldMapper" id="cisOrderWsDTOFieldMapper"> <property name="sourceClass" value="Data" /> <property name="destClass" value="WsDto" /> <property name="fieldMapping"> <map> <entry key="price.discount" value="discount"/> </map> </property>
Custom mapper (extending de.hybris.platform.webservicescommons.mapping.mappers.AbstractCustomMapper) was created for this and solved an issue.
This issue happens in Hybris + Orika, for clean Orika (outside of Hybris) wasn’t able to reproduce this problem.