Camunda服务任务错误:表达式中使用的未知属性

发布于 2025-02-01 08:28:19 字数 1372 浏览 3 评论 0 原文

我创建了一个简单的工作流程,在其中使用服务任务在另一个过程中调用事件子过程,并使用Java代码来执行此操作。我使用实现类型“委托表达式”(见下文)

“在此处输入图像描述”

在运行服务任务时,我会收到以下错误。

提交任务表格时发生了错误: 无法提交任务表54897AF5-DC6B-11EC-85F0-E02BE903A6C0:表达式中使用的未知属性:#{castivalProcess}。原因:无法解析标识符“取消程序”

这是我的Java代码:

package org.example;

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.bpm.engine.runtime.MessageCorrelationResult;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component("cancelProcess")
public class CancelProcess implements JavaDelegate {
    public void execute(DelegateExecution execution) {
        // correlate the message
        RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
        MessageCorrelationResult result = runtimeService.createMessageCorrelation("CANCEL_PROCESS")
                .processInstanceBusinessKey("Order-Process-123")
                .setVariable("employeeName", execution.getVariable("employeeName"))
                .correlateWithResult();
    }
}

请告知。我在这里犯了什么错误。

I created a simple workflow where I am calling an event subprocess in another process using a service task and I am doing this by using a Java code. I configured the java class in the service task using the Implementation type "Delegate Expression" (see below)

enter image description here

I get the following error while running the service task.

An error happened while submitting the task form :
Cannot submit task form 54897af5-dc6b-11ec-85f0-e02be903a6c0: Unknown property used in expression: #{cancelProcess}. Cause: Cannot resolve identifier 'cancelProcess'

Here is my Java code :

package org.example;

import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.camunda.bpm.engine.runtime.MessageCorrelationResult;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component("cancelProcess")
public class CancelProcess implements JavaDelegate {
    public void execute(DelegateExecution execution) {
        // correlate the message
        RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
        MessageCorrelationResult result = runtimeService.createMessageCorrelation("CANCEL_PROCESS")
                .processInstanceBusinessKey("Order-Process-123")
                .setVariable("employeeName", execution.getVariable("employeeName"))
                .correlateWithResult();
    }
}

Please advise. What mistake am I making here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青瓷清茶倾城歌 2025-02-08 08:28:19

您正确使用了实现类型委托表达式和在表达式内部的弹簧bean的名称。如果无法解决组件的名称,则可能是未检测到组件。日志是否显示声明是找到声明的?

Spring的组件扫描仅自动拾取组件,这些组件在您的应用程序中的软件包下方的软件包中声明。
参阅Eg https://wwwwww.baeldung.com/spring-component-scanning

请 将主应用程序类放置在组件类上方的root软件包中。

You correctly used the implementation type delegate expression and inside the expression the name of the spring bean. If the name of the component cannot be resolved then it could be that the component has not been detected. Does the log show that the declaration is found?

Spring's component scan only automatically picks up on components which are declared in a package below the package your Application resides in.
See e.g. https://www.baeldung.com/spring-component-scanning

Try placing your main application class in a root package above the component classes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文