Spring作为后端的JBPM应用无法解析#{expression}表达式问题排查
I’ve run into this exact problem before—Business Central includes all the necessary components to parse those #{variable} expressions automatically, but when building a custom Spring Boot service with the kjar-service structure, you have to manually ensure the right dependencies and configurations are in place. Here’s how to fix it:
1. Add Critical jBPM Dependencies to Your kjar
Looking at your kjar pom, you’re missing the core jBPM modules that handle BPMN parsing and human task expression resolution. Add these to your kjar’s <dependencies> section:
<dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-bpmn2</artifactId> <version>${version.org.kie}</version> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-human-task-core</artifactId> <version>${version.org.kie}</version> </dependency>
These dependencies are responsible for processing the BPMN definition and replacing the #{} expressions with actual process variable values when tasks are created.
2. Verify Service-Side Configuration & Dependencies
Your service uses kie-server-spring-boot-starter, which should include most required components, but let’s make sure expression support isn’t disabled. Add these properties to your Spring Boot application.properties (or yml):
# Enable jBPM expression resolution jbpm.expression.enabled=true # Ensure Kie Server uses proper session configuration (adjust credentials as needed) kie.server.controller.user=kieserver kie.server.controller.password=kieserver1!
If you still see issues, you can explicitly add the Spring integration module for human tasks (though the starter should include it indirectly):
<dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-human-task-spring</artifactId> <version>${version.org.kie}</version> </dependency>
3. Double-Check Process Variable Scope & Assignment
Make sure your codiceEsito variable is set before the task is created in the process flow, and that it’s in the correct scope (process instance scope, not a local task variable). When starting the process, pass the variable explicitly:
Map<String, Object> processVars = new HashMap<>(); processVars.put("codiceEsito", "01"); kieServices.getRuntimeManager() .getRuntimeEngine(EmptyContext.get()) .getKieSession() .startProcess("your-process-definition-id", processVars);
4. Rebuild & Redeploy
After updating dependencies, rebuild your kjar and restart the Spring service:
# In your kjar directory mvn clean install -DskipTests # In your service directory mvn spring-boot:run
Quick Additional Checks
- Confirm your BPMN task’s name is exactly
EndTask-#{codiceEsito}—no typos like${}instead of#{}. - Check your service logs for WARN/ERROR messages related to expression parsing or missing jBPM components; those will point you to any remaining gaps.
Once you’ve gone through these steps, the #{codiceEsito} expression should resolve correctly, and your H2 database will show the task name as EndTask-01 instead of the raw expression.
内容的提问来源于stack exchange,提问作者L_Cleo

