jeecgboot/JeecgBoot · error · IllegalArgumentException
类 {ruleClass} 未实现 IFillRuleHandler 接口
Error message
类 {ruleClass} 未实现 IFillRuleHandler 接口 What it means
Thrown by FillRuleUtil.executeRule after successfully loading ruleClass via reflection when the loaded class does not implement org.jeecg.common.handler.IFillRuleHandler. The isAssignableFrom check fails and an IllegalArgumentException is thrown. Note: because the surrounding try-catch swallows all exceptions (e.printStackTrace then returns null), the exception does not propagate — the method silently returns null.
Source
Thrown at jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/FillRuleUtil.java:87
params.put(key, value);
}
}
if (formData == null) {
formData = new JSONObject();
}
// 包路径白名单校验,防止任意类加载漏洞
if (!ruleClass.startsWith("org.jeecg.")) {
log.error("检测到非法填值规则类加载尝试: {}", ruleClass);
throw new SecurityException("不允许加载非 org.jeecg 包路径下的填值规则类: " + ruleClass);
}
// 通过反射执行配置的类里的方法(先加载类并校验接口,再实例化)
//update-begin---author:scott ---date:20260416 for:【PR#9538】Class.forName使用上下文类加载器,增强部署兼容性-----------
Class<?> clazz = Class.forName(ruleClass, true, Thread.currentThread().getContextClassLoader());
//update-end---author:scott ---date:20260416 for:【PR#9538】Class.forName使用上下文类加载器,增强部署兼容性-----------
if (!IFillRuleHandler.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException("类 " + ruleClass + " 未实现 IFillRuleHandler 接口");
}
IFillRuleHandler ruleHandler = (IFillRuleHandler) clazz.getDeclaredConstructor().newInstance();
return ruleHandler.execute(params, formData);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
}
View on GitHub (pinned to 96fb33f5ec)
Solutions
- Make the configured class implement org.jeecg.common.handler.IFillRuleHandler and override execute(JSONObject params, JSONObject formData).
- Verify the fully-qualified class name in sys_fill_rule.rule_class matches the actual class and package.
- Ensure the class has a public no-arg constructor (getDeclaredConstructor().newInstance() is used).
- Because the outer catch swallows this, check application logs for the printed stack trace when executeRule unexpectedly returns null.
Example fix
// before
package org.jeecg.modules.demo;
public class MyRule { // does not implement IFillRuleHandler
public Object execute() { return "x"; }
}
// after
package org.jeecg.modules.demo;
import org.jeecg.common.handler.IFillRuleHandler;
public class MyRule implements IFillRuleHandler {
public MyRule() {}
@Override
public Object execute(JSONObject params, JSONObject formData) { return "x"; }
} Defensive patterns
Strategy: try-catch
Validate before calling
Class<?> clazz = Class.forName(ruleClass);
if (!IFillRuleHandler.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(ruleClass + " 未实现 IFillRuleHandler");
} Type guard
null
Try / catch
// Note: FillRuleUtil.executeRule swallows all exceptions and returns null.
// Check logs for the printed stack trace when the result is unexpectedly null.
Object result = FillRuleUtil.executeRule(ruleCode, formData);
if (result == null) {
log.warn("填值规则 [{}] 执行失败或未配置,请检查 rule_class 与接口实现", ruleCode);
} Prevention
- Ensure configured classes implement IFillRuleHandler and have a no-arg constructor.
- Because executeRule swallows exceptions, rely on logs to diagnose null returns.
- Validate rule_class against the classpath during configuration.
When it happens
Trigger: A sys_fill_rule row points rule_class to a valid org.jeecg.* class that exists on the classpath but does not implement IFillRuleHandler; or the class was refactored/renamed and no longer implements the interface.
Common situations: Class name copy-pasted incorrectly into rule_class; the handler class was an early prototype that never implemented the interface; a version upgrade changed the interface or moved it; the configured class is a plain POJO rather than a rule handler.
Related errors
- 不允许加载非 org.jeecg 包路径下的填值规则类: {ruleClass}
- {className} not found!
- 数据源URL配置格式不正确!
- 动态数据源连接失败,dbKey:{dbKey}
- DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/df50e1d03f253449.
Report an issue: GitHub.