flowable报错java.time.LocalDateTime cannot be cast to java.lang.String

报错信息

Caused by: java.lang.ClassCastException: java.time.LocalDateTime cannot be cast to java.lang.String

请添加图片描述

查看源码位置

请添加图片描述

代码片段如下

Object tmpDateExecuted = rs.get("DATEEXECUTED");
Date dateExecuted = null;
if (tmpDateExecuted instanceof Date) {
    dateExecuted = (Date)tmpDateExecuted;
} else {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
        dateExecuted = df.parse((String)tmpDateExecuted);
    } catch (ParseException var24) {
    }
}

通过debug

请添加图片描述

得出结论

高版本(我这里用的8.0.30)的mysql驱动包返回的dateExecuted类型为LocalDataTime,在强转为String的时候报错

解决方法

切换版本为8.0.22

请添加图片描述

至此,启动成功

需要注意的是:8.0.22版本及以下存在这两个漏洞:

CVE-2021-2471CVE-2022-21363,自己要做好取舍

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
非常抱歉,我之前的回答有误。在 Flowable 6.5 中,确实没有 `org.flowable.engine.delegate.Expression` 接口。 如果需要处理复杂条件,可以使用 `org.flowable.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior` 中的 `org.flowable.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior#evaluateConditions(DelegateExecution)` 方法,该方法可以通过代理类计算条件表达式的值。 以下是一个使用代理类处理复杂条件的示例: 1. 定义一个 Java 类,实现 `org.flowable.engine.delegate.JavaDelegate` 接口。该接口用于执行 Java 代码,并可以访问流程实例的变量。 ``` public class MyJavaDelegate implements JavaDelegate { @Override public void execute(DelegateExecution execution) { // 获取 execution 中的变量,根据变量值计算条件表达式的值 // 将计算结果设置为 execution 的变量 } } ``` 2. 在 ExclusiveGateway 中定义条件表达式,值为代理类的实例。 ``` <exclusiveGateway id="exclusiveGateway1" name="Exclusive Gateway"> <extensionElements> <activiti:executionListener expression="${myJavaDelegate}" event="start" /> </extensionElements> <condition id="flow1Condition" name="flow1"> <!-- 空值,代理类中计算条件表达式的值 --> </condition> <condition id="flow2Condition" name="flow2"> <!-- 空值,代理类中计算条件表达式的值 --> </condition> </exclusiveGateway> ``` 3. 在流程启动时,将代理类的实例设置为 execution 的变量。 ``` Map<String, Object> variables = new HashMap<>(); variables.put("myJavaDelegate", new MyJavaDelegate()); runtimeService.startProcessInstanceByKey("myProcess", variables); ``` 4. 在代理类中可以通过 DelegateExecution 对象获取流程实例的变量,根据变量值计算条件表达式的值,并将计算结果设置为 execution 的变量。 ``` public class MyJavaDelegate implements JavaDelegate { @Override public void execute(DelegateExecution execution) { // 获取 execution 中的变量 Object variable = execution.getVariable("myVariable"); // 根据变量值计算条件表达式的值 boolean conditionValue = true; // 假设计算结果为 true // 将计算结果设置为 execution 的变量 execution.setVariable("flow1Condition", conditionValue); execution.setVariable("flow2Condition", !conditionValue); } } ``` 以上就是一个使用代理类处理复杂条件的示例。希望能够对你有所帮助。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值