on 11-22-2022 6:39 AM
Hi Team,
Currently we are upgrading our SAP commerece hybris from 6.1 to 2105.We are managing our storefront with AEM and using hybris to manage products,cart and orders.As part of this we developed REST API's to fetch products from hybris.
This is how our Rest API url looks like to fetch a product:
https://localhost:1905/trwebservices/v1/testcountry/products/1234
While upgrading to 1905,the above URL giving 500 server error,throwing a error in backend.tried many solutions but none of the solutions is working.below is the stacktrace
"SEVERE: Servlet.service() for servlet [springmvc] in context with path [/trwebservices] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.thomsonreuters.ecom.facades.product.data.TRPriceDataTypeUtil]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.thomsonreuters.ecom.facades.product.data.TRPriceDataTypeUtil and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.thomsonreuters.ecom.facades.product.data.TRProductData["price"]->com.thomsonreuters.ecom.facades.product.data.TRPriceData["util"])] with root cause
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.thomsonreuters.ecom.facades.product.data.TRPriceDataTypeUtil and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.thomsonreuters.ecom.facades.product.data.TRProductData["price"]->com.thomsonreuters.ecom.facades.product.data.TRPriceData["util"])
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)"
Tried Solutions:
1.Added getters and setters in TRPriceDataTypeUtil class.and made access specifiers public.still same error.
2.Added @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) in TRPriceDataTypeUtil.Still same issue.
3.Created Objectmapper class and added this:
ObjectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);.Still same issue.
4.Added latest jackson jars and changed imports,this time it was not showing the error but in frontend it is giving 500
4.Removed the complete class TRPriceDataTypeUtil but still showing same issue.
Please suggest?
I get almost the same error when doing an expand with filter CqnSelect
ERR Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class com.sap.cds.impl.parser.token.RefSegmentImpl$FilteredSegmentImpl and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.Collections$SingletonList[0])
for this type of expand
Select.from(ASSORTMENT) .columns( Assortment_::_all, a -> a.toCompBP() .filter(bp -> bp.anyMatch(ofBusinessPartnerFinal)) .expand(AssortmentBusinessPartner_::_all), a -> a.toCompProduct() .filter(p -> p.anyMatch(ofProductFinal)) .expand(AssortmentProduct_::_all) ) .where(fullPredicate);
I tried with custom objectMapper Bean with disable(SerializationFeature.FAIL_ON_EMPTY_BEANS) and the error is still alive
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sharada,
The log shows Jackson is trying to serialize a bean with no attributes nor methods
You have different ways to fix it:
=== method1: avoid using any empty object ===
Iterate over your code to avoid empty object, something like this: "new Object()", if yes, replace it with "null"
=== method 2: avoid failure on empty object ===
ObjectMapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); (for jackson < 2.*)
or
ObjectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
Normally, method 1 is better since it doesn't change Jackson default behavior during fixing the problem.
Hopefully, it can help you a little.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please find detailed log . stacktrace.txt
User | Count |
---|---|
4 | |
1 | |
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.