cancel
Showing results for 
Search instead for 
Did you mean: 

FreeGiftPromotion not working with coupon Code

0 Kudos
506

error-log-1.txtI am using CX2011 and wanted to add a Free product after applying a coupon into the cart.
Here I am facing issue while adding free gift with following error:
please see the attachment for full log

DEBUG [hybrisHTTP16] [MedionRequestCheckoutLoggerFilter] User:anonymous Cart:00004000 http:POST@/de/shop/cart/voucher/apply with:voucherCode=[KATRINTEST] Begin
ERROR [hybrisHTTP16] [DefaultCommerceRuleEngineService] Rule evaluation failed with message 'Exception executing consequence for rule "2b59cf54-47dd-4ea0-84de-0adc66b77a88" in de.hybris.platform.droolsruleengine: java.lang.RuntimeException: cannot invoke method: executeAction' for facts: [de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@cfe53465, de.hybris.platform.ruleengineservices.rao.CustomerSupportRAO@9e61, de.hybris.platform.ruleengineservices.rao.WebsiteGroupRAO@c213f851, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@799dd278, de.hybris.platform.couponservices.rao.CouponRAO@f1465521, de.hybris.platform.ruleengineservices.rao.UserRAO@2ea4ed4e, de.hybris.platform.ruleengineservices.rao.UserGroupRAO@80aab180, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@2436531c, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@f5f578bf, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@b36510e8, de.hybris.platform.ruleengineservices.rao.OrderEntryRAO@3ba0e88e, de.hybris.platform.ruleengineservices.rao.CartRAO@ba08e99b, de.hybris.platform.ruleengineservices.rrd.EvaluationTimeRRD@f679c34, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@be112445, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@8f8dea3a, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@c3aab672, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@30168b, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@3005dc1b, de.hybris.platform.ruleengineservices.rao.DeliveryModeRAO@80b70108, de.hybris.platform.ruleengineservices.rao.RuleEngineResultRAO@556fcfee, de.hybris.platform.droolsruleengineservices.agendafilter.impl.DefaultRuleAndRuleGroupExecutionTracker@16297f5].
 org.kie.api.runtime.rule.ConsequenceException: Exception executing consequence for rule "2b59cf54-47dd-4ea0-84de-0adc66b77a88" in de.hybris.platform.droolsruleengine: java.lang.RuntimeException: cannot invoke method: executeAction
	at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.common.DefaultAgenda.handleException(DefaultAgenda.java:1242) ~[drools-core-7.21.0.Final.jar:?]
	at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:439) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.phreak.RuleExecutor.fireActivation(RuleExecutor.java:380) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:136) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:89) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:34) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1062) ~[drools-core-7.21.0.Final.jar:?]
	at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1009) ~[drools-core-7.21.0.Final.jar:?]
	at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1001) ~[drools-core-7.21.0.Final.jar:?]
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1330) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1321) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:103) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:34) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:160) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
..................
..................
Caused by: java.lang.NullPointerException: Cannot invoke "java.math.BigDecimal.setScale(int, int)" because "amount" is null
	at de.hybris.order.calculation.money.Money.<init>(Money.java:121) ~[ordercalculationserver.jar:?]
	at de.hybris.platform.ruleengineservices.converters.OrderEntryRaoToNumberedLineItemConverter.convert(OrderEntryRaoToNumberedLineItemConverter.java:37) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.converters.OrderEntryRaoToNumberedLineItemConverter.convert(OrderEntryRaoToNumberedLineItemConverter.java:1) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.converters.AbstractOrderRaoToOrderConverter.convertEntriesToLineItems(AbstractOrderRaoToOrderConverter.java:95) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.converters.AbstractOrderRaoToOrderConverter.convert(AbstractOrderRaoToOrderConverter.java:79) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.converters.AbstractOrderRaoToOrderConverter.convert(AbstractOrderRaoToOrderConverter.java:1) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.calculation.impl.DefaultRuleEngineCalculationService.addOrderEntryLevelDiscount(DefaultRuleEngineCalculationService.java:167) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.calculation.impl.DefaultRuleEngineCalculationService.addOrderEntryLevelDiscount(DefaultRuleEngineCalculationService.java:158) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.rule.evaluation.actions.impl.RuleOrderEntryPercentageDiscountRAOAction.processOrderEntry(RuleOrderEntryPercentageDiscountRAOAction.java:56) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.rule.evaluation.actions.impl.RuleFreeGiftRAOAction.performAction(RuleFreeGiftRAOAction.java:102) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.rule.evaluation.actions.impl.RuleFreeGiftRAOAction.performActionInternal(RuleFreeGiftRAOAction.java:54) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruleengineservices.rule.evaluation.actions.AbstractRuleExecutableSupport.performAction(AbstractRuleExecutableSupport.java:96) ~[ruleengineservicesserver.jar:?]
	at de.hybris.platform.ruledefinitions.actions.AbstractRAOActionAware.executeAction(AbstractRAOActionAware.java:43) ~[ruledefinitionsserver.jar:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.mvel2.optimizers.impl.refl.nodes.MethodAccessor.getValue(MethodAccessor.java:40) ~[mvel2-2.4.4.Final.jar:?]
	at org.mvel2.optimizers.impl.refl.nodes.VariableAccessor.getValue(VariableAccessor.java:37) ~[mvel2-2.4.4.Final.jar:?]
	at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:108) ~[mvel2-2.4.4.Final.jar:?]
	at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85) ~[mvel2-2.4.4.Final.jar:?]
	at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123) ~[mvel2-2.4.4.Final.jar:?]
	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119) ~[mvel2-2.4.4.Final.jar:?]
	at org.mvel2.MVEL.executeExpression(MVEL.java:929) ~[mvel2-2.4.4.Final.jar:?]
	at org.drools.core.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:110) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	at org.drools.core.phreak.RuleExecutor.innerFireActivation(RuleExecutor.java:432) ~[drools-core-7.21.0.Final.jar:7.21.0.Final]
	... 192 more

Accepted Solutions (0)

Answers (2)

Answers (2)

mansurarisoy
Contributor
0 Kudos

You are getting the error at Money.class which is triggered from OrderEntryRaoToNumberedLineItemConverter

Caused by: java.lang.NullPointerException: Cannot invoke "java.math.BigDecimal.setScale(int, int)" because "amount" is null
	at de.hybris.order.calculation.money.Money.<init>(Money.java:121) ~[ordercalculationserver.jar:?]
	at de.hybris.platform.ruleengineservices.converters.OrderEntryRaoToNumberedLineItemConverter.convert(OrderEntryRaoToNumberedLineItemConverter.java:37) ~[ruleengineservicesserver.jar:?]

The line causing the error is possibly the following

Money money = new Money(entryRao.getPrice(), (Currency)this.getAbstractOrderRaoToCurrencyConverter().convert(rao));
And the constructor of the Money class is as follows
public Money(BigDecimal amount, Currency currency) {
    if (currency == null) {
        throw new IllegalArgumentException("Currency cannot be null");
    } else {
        this.amount = amount.setScale(currency.getDigits(), 1);
        this.currency = currency;
    }
}
So, if the amount parameter is null, then this code will throw an error. What I suggest is you to investigate the value of entryRao.getPrice() in debug and look for the places where this value is set as null. There may be some custom code which prevents price attribute to be populated. It may happen if you customized OrderEntryRaoPopulator which is defined ruleengineservices extension and sets price attribute of OrderEntryRao.
0 Kudos
  1. Could you please attach your backoffice screenshot of condition and Action for the promotion created.
  2. Do you have any custom condition/action or both (coupon and free gift) are OOTB only?
0 Kudos

here you go.