on ‎2019 Oct 24 9:47 AM
[MappingJackson2HttpMessageConverter] Failed to evaluate Jackson deserialization for type [[simple type, class de.hybris.platform.acceleratorstorefrontcommons.forms.AddToCartOrderForm]]: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "url": de.hybris.platform.core.model.media.MediaModel#setUrl(1 params) vs de.hybris.platform.core.model.media.MediaModel#setURL(1 params) WARN [hybrisHTTP26] [MappingJackson2HttpMessageConverter] Failed to evaluate Jackson deserialization for type [[simple type, class de.hybris.platform.acceleratorstorefrontcommons.forms.AddToCartOrderForm]]: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "url": de.hybris.platform.core.model.media.MediaModel#setUrl(1 params) vs de.hybris.platform.core.model.media.MediaModel#setURL(1 params) ERROR [hybrisHTTP26] [KaterraExceptionHandlerAdvice] Unhandled exception - org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported
Request clarification before answering.
For resolving this issue, you need to follow below steps.
1.Create new class- MediaModelMixin.java
import com.fasterxml.jackson.annotation.JsonIgnore;
abstract class MediaModelMixin {
@JsonIgnore
public abstract String getUrl();
@JsonIgnore
public abstract String getUrl2();
@JsonIgnore
public abstract String setUrl();
}
2.Override the addKeyDeserializer method of OOTB class- ItemObjectMapperConfiguration.class in your SolrObjectMapperHolder.java
Attached sample code
SimpleModule itemObjectModule = new SimpleModule("itemObjectModule", Version.unknownVersion());
itemObjectModule.addKeyDeserializer(AttributeDescriptorModel.class, new KeyDeserializer() {
public Object deserializeKey(String s, DeserializationContext deserializationContext) throws IOException {
return null;
}
});
OBJECT_MAPPER.addMixIn(MediaModel.class, MediaModelMixin.class);
OBJECT_MAPPER.registerModule(itemObjectModule);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think still on other upper hybris version we have this issue, I was facing this on hybris 2211.31, so this is the fix in case still if you are facing issue.
Resolution:
Step 1) Define MediaModelMixin class in com.<your_custom_core_extension_name>.commerce.core.mixin.CustomJacksonConverter
import com.fasterxml.jackson.annotation.JsonIgnore;
public abstract class MediaModelMixin {
public MediaModelMixin() {
}
@JsonIgnore
public abstract String getUrl2();
@JsonIgnore
public abstract String getUrl();
}
Step 2) Define CustomJacksonConverter.class in any core extension /src folder, for example like this package : com.<your_custom_core_extension_name>.commerce.core.mixin.CustomJacksonConverter
public class CustomJacksonConverter extends MappingJackson2HttpMessageConverter {
public CustomJacksonConverter() {
super();
configureObjectMapper();
}
public CustomJacksonConverter(ObjectMapper objectMapper) {
super(objectMapper);
configureObjectMapper();
}
private void configureObjectMapper() {
ObjectMapper mapper = getObjectMapper();
// Register the mixin for MediaModel
mapper.addMixIn(MediaModel.class, MediaModelMixin.class);
// Create module for handling multiple model types
SimpleModule itemObjectModule = new SimpleModule("itemObjectModule", Version.unknownVersion());
// Add key deserializer for AttributeDescriptorModel
itemObjectModule.addKeyDeserializer(AttributeDescriptorModel.class, new KeyDeserializer() {
@Override
public Object deserializeKey(String s, DeserializationContext deserializationContext) throws IOException {
return null;
}
});
// Add key deserializer for ClassificationAttributeUnitModel
itemObjectModule.addKeyDeserializer(ClassificationAttributeUnitModel.class, new KeyDeserializer() {
@Override
public Object deserializeKey(String s, DeserializationContext deserializationContext) throws IOException {
return null;
}
});
// Register the module with both deserializers
mapper.registerModule(itemObjectModule);
}
}
Step 3) in all your b2c and b2b extensions you use - get it registered like this with spring-mvc-config.xml which will make sure deserializer getting added in message-converters:
<mvc:annotation-driven ignore-default-model-on-redirect="true" validator="validator">
<mvc:message-converters>
<bean class="com.<your_custom_core_extension_name>.commerce.core.mixin.CustomJacksonConverter" />
<bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
</mvc:message-converters>
</mvc:annotation-driven>
Step 4) build, restart and test
Anyone found solution for this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prashant Bharti,
Is there any solution produced?
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.