我在hybris 1808中创建了一个促销,但是当我尝试发布该促销时,它失败了。同样的促销活动也在1808年的Vanilla Hybris中发挥作用
我在localextension.xml中添加了以下属性,并尝试过但仍面临相同的问题
我希望升级状态为“发布”,但是发布时却失败,并显示以下错误日志:
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 *************************************
答案 0 :(得分:1)
您正在使用哪个版本的hybris?
因为我在发布促销时从6.3升级到6.7时遇到了这个问题。
我已经在6.3的自定义类中重写了该方法,如下所示:
@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');
...
必须更改类DefaultDroolsRuleTargetCodeGenerator中重写的方法,以包含droolRule uuid而不是rule uuid,这是6.7中OOTB DefaultDroolsRuleTargetCodeGenerator类中合并的更改
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");
这解决了上面的错误。
希望这会有所帮助。 编码愉快。