0

I have created a promotion in hybris 1808 but when I am trying to publish the promotion it's Failing. The same promotion is working in 1808 Vanilla Hybris

I have added following properties in localextension.xml and tried but still facing the same issue

  1. promotionenginesamplesaddon
  2. promotionengineatddtests

I expected the promotion status to Publish but it's failing while publishing with following error logs :

19.04.23 17:54:40:527   INFO    *************************************
19.04.23 17:54:40:535   INFO    Starting RuleEngineCompilePublishJob
19.04.23 17:54:40:535   INFO    *************************************
19.04.23 17:54:44:903   ERROR   The rule compilation finished with errors
19.04.23 17:54:44:910   ERROR   Exception caught - de.hybris.platform.servicelayer.exceptions.ModelSavingException: [de.hybris.platform.droolsruleengineservices.interceptors.DroolsRuleValidateInterceptor@3d9f547f]:rule(code:testPromotion) The drl content does not contain the matching rule declaration with the value of your hybris rule's uuid attribute. Please adjust the uuid of your hybris rule and/or add: rule "2e0e0ac2-7475-44c1-9114-07a0d7174534" (i.e. putting the rule uuid in double-quotes) in your drl content.
19.04.23 17:54:44:915   INFO    *************************************
19.04.23 17:54:44:915   INFO    RuleEngineCompilePublishJob finished with errors
19.04.23 17:54:44:915   INFO    *************************************
S Ahmed
  • 1,454
  • 1
  • 8
  • 14
Aishwarya
  • 21
  • 4

1 Answers1

1

Which verion of hybris are you using?

Because I faced this while upgrading from 6.3 to 6.7 while publishing the promotion.

I had overridden the method in my custom class in 6.3 which looks has follows:

@Override
    protected String generateRuleContentRule(final DroolsRuleGeneratorContext context, final String actions, final String metadata)
    {
        final AbstractRuleModel rule = context.getRuleCompilerContext().getRule();
        final Map variables = context.getVariables();
        final StringBuilder buffer = new StringBuilder(4096);
        buffer.append("rule \"").append(rule.getUuid()).append("\"\n");
        buffer.append("@ruleCode(\"").append(rule.getCode()).append("\")\n");
        buffer.append(metadata);
        buffer.append("dialect \"mvel\" \n");
        buffer.append("salience ").append(rule.getPriority()).append('\n');

...

This overridden method from the class DefaultDroolsRuleTargetCodeGenerator had to be changed to include droolRule uuid rather than rule uuid which is the change incorporated in OOTB DefaultDroolsRuleTargetCodeGenerator class in 6.7

     protected String generateRuleContentRule(DroolsRuleGeneratorContext context, String actions, String metadata) {
    AbstractRuleModel rule = context.getRuleCompilerContext().getRule();
    DroolsRuleModel droolsRule = context.getDroolsRule();
    StringBuilder buffer = new StringBuilder(4096);
    buffer.append("rule \"").append(droolsRule.getUuid()).append("\"\n");
    buffer.append("@ruleCode(\"").append(rule.getCode()).append("\")\n");
    buffer.append("@moduleName(\"").append(context.getRuleCompilerContext().getModuleName()).append("\")\n");
    buffer.append(metadata);
    buffer.append("dialect \"mvel\" \n");

This resolved the error above.

Hope this helps. Happy Coding.

viji shetty
  • 41
  • 2
  • 9