You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maven测试中无法找到DMN FEEL函数问题求助

问题排查:DMN表达式在KIE Sandbox正常但Maven测试失败(找不到date函数)

问题核心

DMN决策模型中使用以下表达式计算年龄:

years and months duration(date(DOB), today()).years

该表达式在KIE Sandbox运行正常,但通过mvn test执行.scesim测试文件时,报错无法找到date函数:

[ERROR] Errors:
[ERROR]   #1: Failure reason: The decision "Age" has not been successfully evaluated: FEEL ERROR while evaluating literal expression 'years and months duration(date(DOB), today()).year... [string clipped after 50 chars, total length is 51]': Unable to find function 'date( lass org.kie.dmn.feel.runtime.functions.extended.DateFunctio )' (testAge)

可能原因及解决方案

1. KIE版本不一致

KIE Sandbox使用的DMN引擎版本与本地Maven依赖版本不匹配,date扩展函数可能仅在特定版本中提供。

  • 解决步骤:
    • 查看KIE Sandbox的版本(通常在Sandbox的「关于」或设置页面)。
    • 在Maven pom.xml中统一所有org.kie相关依赖的版本为Sandbox使用的版本,例如:
      <properties>
          <kie.version>7.71.0.Final</kie.version> <!-- 替换为Sandbox对应版本 -->
      </properties>
      

2. 缺失FEEL扩展函数依赖

本地Maven项目未引入包含date扩展函数的依赖包。

  • 解决步骤:
    在pom.xml中添加以下依赖:
    <dependency>
        <groupId>org.kie</groupId>
        <artifactId>kie-dmn-core</artifactId>
        <version>${kie.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.kie</groupId>
        <artifactId>kie-dmn-feel-functions</artifactId>
        <version>${kie.version}</version>
        <scope>test</scope>
    </dependency>
    

3. DMN引擎未加载扩展函数

Maven测试时的DMN引擎初始化未启用FEEL扩展函数。

  • 解决步骤:
    确保测试代码中正确初始化DMN运行时,使用KieContainer加载模型(自动包含扩展函数):
    KieServices kieServices = KieServices.Factory.get();
    KieContainer kieContainer = kieServices.getKieClasspathContainer();
    DMNRuntime dmnRuntime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
    

4. 输入变量类型不匹配

.scesim测试文件中DOB变量的类型可能不是日期类型,导致date()函数无法解析。

  • 解决步骤:
    检查scesim文件中DOB的列类型,确保设置为Date类型而非字符串;若使用字符串格式,需调整表达式为标准FEEL格式:date("2000-01-01")(硬编码场景)或确认输入变量已被正确映射为日期类型。

额外排查步骤

  • 执行mvn dependency:tree检查是否存在依赖版本冲突,排除低版本的org.kie相关依赖。
  • 简化表达式,单独测试date(DOB)是否能正常运行,逐步定位问题点。

内容的提问来源于stack exchange,提问作者maresmar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 15:40:23