There is a process task in sap order process that deletes the existing order entries from the order and adds the entries from the sales order response that has line items as well. During the process, Im getting “item 9294277673006 no longer valid (was removed): object no longer valid” error while placing some of the orders.
I suspect performing Modelservice.removeall and then accessing the same oldOrderEntries in the copyPricesForMatchingProducts is causing the issue. but Im not sure how the stored entries are not accessible though the model service removed them that too only for few requests. Please help me on this.
public OrderModel convert(List<List<CPQInboundOrderLineItemDTO>> cpqInboundOrderLineItemDTOS, OrderModel orderModel) throws ConversionException {
CatalogVersionModel catalogVersionOfProducts = null;
List<AbstractOrderEntryModel> newOrderEntries = new ArrayList<>();
List<AbstractOrderEntryModel> oldOrderEntries = orderModel.getEntries();
if (CollectionUtils.isNotEmpty(orderModel.getEntries())) {
catalogVersionOfProducts = orderModel.getEntries().get(0).getProduct().getCatalogVersion();
getModelService().removeAll(orderModel.getEntries());
}
for (List<CPQInboundOrderLineItemDTO> lineItemList : cpqInboundOrderLineItemDTOS) {
for (CPQInboundOrderLineItemDTO lineItem : lineItemList) {
OrderEntryModel orderEntryModel = getModelService().create(OrderEntryModel.class);
orderEntryModel.setEntryNumber(lineItem.getItemNumber());
copyPricesForMatchingProducts(orderEntryModel, oldOrderEntries);
}
private void copyPricesForMatchingProducts(OrderEntryModel orderEntryModel, List<AbstractOrderEntryModel> oldOrderEntries) {
if (CollectionUtils.isNotEmpty(oldOrderEntries)) {
for (AbstractOrderEntryModel oldOrderEntryModel : oldOrderEntries) {
if (oldOrderEntryModel.getProduct().getCode() == orderEntryModel.getProduct().getCode()) {
orderEntryModel.setBasePrice(oldOrderEntryModel.getBasePrice());
orderEntryModel.setSalesOrgCountryPrice(oldOrderEntryModel.getSalesOrgCountryPrice());
}
}
}
}
Error:
item 8975006367790 no longer valid (was removed): object no longer valid”,”thrown”:{“commonElementCount”:0,”localizedMessage”:”item 8975006367790 no longer valid (was removed): object no longer valid”,”message”:”item 8975006367790 no longer valid (was removed): object no longer valid”,”name”:”de.hybris.platform.jalo.JaloObjectNoLongerValidException”,”extendedStackTrace”:[{“class”:”de.hybris.platform.jalo.Item$CachedGetter”,”method”:”get”,”file”:”Item.java”,”line”:740,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.jalo.ExtensibleItem”,”method”:”getProperty”,”file”:”ExtensibleItem.java”,”line”:343,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.jalo.order.GeneratedAbstractOrderEntry”,”method”:”getBasePrice”,”file”:”GeneratedAbstractOrderEntry.java”,”line”:106,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”jdk.internal.reflect.NativeMethodAccessorImpl”,”method”:”invoke0″,”file”:”NativeMethodAccessorImpl.java”,”line”:-2,”exact”:false,”location”:”?”,”version”:”?”},{“class”:”jdk.internal.reflect.NativeMethodAccessorImpl”,”method”:”invoke”,”file”:”NativeMethodAccessorImpl.java”,”line”:77,”exact”:false,”location”:”?”,”version”:”?”},{“class”:”jdk.internal.reflect.DelegatingMethodAccessorImpl”,”method”:”invoke”,”file”:”DelegatingMethodAccessorImpl.java”,”line”:43,”exact”:false,”location”:”?”,”version”:”?”},{“class”:”java.lang.reflect.Method”,”method”:”invoke”,”file”:”Method.java”,”line”:568,”exact”:false,”location”:”?”,”version”:”?”},{“class”:”de.hybris.platform.jalo.type.ReflectionAttributeAccess$AttributeMethod”,”method”:”invokeGetter”,”file”:”ReflectionAttributeAccess.java”,”line”:753,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.jalo.type.ReflectionAttributeAccess”,”method”:”getValue”,”file”:”ReflectionAttributeAccess.java”,”line”:959,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.jalo.Item”,”method”:”getAttribute”,”file”:”Item.java”,”line”:1921,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.servicelayer.internal.model.impl.JaloPersistenceObject”,”method”:”readRawValue”,”file”:”JaloPersistenceObject.java”,”line”:110,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.servicelayer.internal.converter.impl.ItemModelConverter”,”method”:”readSingleAttribute”,”file”:”ItemModelConverter.java”,”line”:1447,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.servicelayer.internal.converter.impl.ItemAttributeProvider”,”method”:”getAttribute”,”file”:”ItemAttributeProvider.java”,”line”:110,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.servicelayer.model.ItemModelContextImpl”,”method”:”loadUnlocalizedAttribute”,”file”:”ItemModelContextImpl.java”,”line”:285,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.servicelayer.model.ItemModelContextImpl”,”method”:”getValue”,”file”:”ItemModelContextImpl.java”,”line”:245,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.servicelayer.model.ItemModelContextImpl”,”method”:”getPropertyValue”,”file”:”ItemModelContextImpl.java”,”line”:261,”exact”:false,”location”:”coreserver.jar”,”version”:”?”},{“class”:”de.hybris.platform.core.model.order.AbstractOrderEntryModel”,”method”:”getBasePrice”,”file”:”AbstractOrderEntryModel.java”,”line”:262,”exact”:false,”location”:”models.jar”,”version”:”?”},{“class”:”com.octanner.pricing.converter.impl.CPQInboundOrderLineItemConverter”,”method”:”copyPricesForMatchingProducts”,”file”:”CPQInboundOrderLineItemConverter.java”,”line”:93,”exact”:false,”location”:”octsegmentpricingserver.jar”,”version”:”?”}