spring-bootactivitijava-17

Consider defining a bean of type 'org.activiti.engine.RuntimeService' in your configuration


I am working on Spring Activiti using Java 17 and getting this error. I have initialized and used RuntimeService in my code as follow

@Service
public class BPMNTaskService
{
    @Autowired
    private RuntimeService runtimeService;
    
    public String startProcess()
    {
        return runtimeService.startProcessInstanceById("queueSegregation").getActivityId();
    }
}

I have many articles including this Getting started with Activiti and Spring Boot

And getting this error

Field runtimeService in com.netsol.ps.process.service.BPMNTaskService required a bean of type 'org.activiti.engine.RuntimeService' that could not be found.

The injection point has the following annotations:

- @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:
Consider defining a bean of type 'org.activiti.engine.RuntimeService' in your configuration.

I am using latest dependencies for all with JDK 17 and with Spring boot 3.0.5. Here are the dependencies in pom.xml

<dependency>
    <groupId>org.codehaus.groovy</groupId> 
    <artifactId>groovy-all</artifactId> 
    <version>3.0.7</version> 
    <type>pom</type> 
</dependency> 

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter</artifactId> 
    <version>2.6.3</version> 
</dependency> 

<dependency> 
    <groupId>org.activiti</groupId> 
    <artifactId>activiti-spring-boot-starter-basic</artifactId> 
    <version>6.0.0</version> 
</dependency>

I have already tried with the following dependencies instead of above mentioned.

<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-spring-boot-starter</artifactId>
    <version>${activiti.version}</version>
</dependency>

<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-engine</artifactId>
    <version>${activiti.version}</version>
</dependency>

<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-spring</artifactId>
    <version>${activiti.version}</version>
</dependency>

Solution

  • The issue was due to the version compatibility. The most compatible versions are JDK 17, Spring Boot 2.5.0 and activiti 7.1.0.M6. Given below are the dependencies used

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-spring-boot-starter</artifactId>
        <version>${activiti.version}</version>
    </dependency>
    
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-engine</artifactId>
        <version>${activiti.version}</version>
    </dependency>
    
    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-spring</artifactId>
        <version>${activiti.version}</version>
    </dependency>