cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Quick Order throwing exception Hybris 1905

Former Member
1,602

[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

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Likes

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);

mandala2
Newcomer
0 Likes

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

0 Likes

Anyone found solution for this?

0 Likes

Hi Prashant Bharti,

Is there any solution produced?

Regards,

0 Likes

Have you found any solution for this