Hi
I'm finding it difficult to configure Activiti into a Spingboot application api.
First of all is it a viable thing to embed Activiti into an API type application for use within that application or should Activiti be run standalone - we are not going Activiti 7 while its in early release stages.
The error is due to bean definition but I'm not sure where the beans should be defined and how - if thats correct approach for version 6. Our standards with Springhboot 2 is to annotate beans in java rather than xml context.
any pointers to relevant pages appreciated
so far I have...
pom
<activiti.version>6.0.0</activiti.version>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>${activiti.version}</version>
</dependency>
main.../resouces/processes/one-task-process-bpm20.xml
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples">
<process id="oneTaskProcess" name="The One Task Process">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" />
<userTask id="theTask" name="my task" />
<sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
Applicatio
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public CommandLineRunner init(final RepositoryService repositoryService,
final RuntimeService runtimeService,
final TaskService taskService) {
return new CommandLineRunner() {
@Override
public void run(String... strings) throws Exception {
System.out.println("Number of process definitions : "
+ repositoryService.createProcessDefinitionQuery().count());
System.out.println("Number of tasks : " + taskService.createTaskQuery().count());
runtimeService.startProcessInstanceByKey("oneTaskProcess");
System.out.println("Number of tasks after process start: " + taskService.createTaskQuery().count());
}
};
}
}
and getting error
APPLICATION FAILED TO START\r\n***************************\r\n\r\nDescription:\r\n\r\nParameter 0 of method init in com.santech.gcb.org.Application required a bean of type 'org.activiti.engine.RepositoryService' that could not be found.\r\n\r\n\r\nAction:\r\n\r\nConsider defining a bean of type 'org.activiti.engine.RepositoryService' in your configuration.\r\n","logger_name":"org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter","thread_name":"restartedMain","level":"ERROR","level_value":40000}
discovered activiti-spring dependency for pom.xml
added @Bean's to Application.java
/*
* Activiti workflow configuration start
* remove from here to end if not required
*/
@Bean
public CommandLineRunner init(final RepositoryService repositoryService,
final RuntimeService runtimeService,
final TaskService taskService) {
return new CommandLineRunner() {
@Override
public void run(String... strings) throws Exception {
System.out.println("Number of process definitions : "
+ repositoryService.createProcessDefinitionQuery().count());
System.out.println("Number of tasks : " + taskService.createTaskQuery().count());
runtimeService.startProcessInstanceByKey("oneTaskProcess");
System.out.println("Number of tasks after process start: " + taskService.createTaskQuery().count());
}
};
}
@Bean
public SpringProcessEngineConfiguration processEngineConfiguration() {
return new SpringProcessEngineConfiguration();
}
@Bean
public ProcessEngineFactoryBean processEngine() {
ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean();
factoryBean.setProcessEngineConfiguration(processEngineConfiguration());
return factoryBean;
}
@Bean
public RepositoryService repositoryService() {
return processEngine().getProcessEngineConfiguration().getRepositoryService();
}
@Bean RuntimeService runtimeService(){
return processEngine().getProcessEngineConfiguration().getRuntimeService();
}
@Bean TaskService taskService(){
return processEngine().getProcessEngineConfiguration().getTaskService();
}
/*
* Activiti workflow configuration end
* remove to here from start if not required
*/
API App not starting but errors not clear yet - suspect the run() method isn't appropriate in this app
Process finished with exit code 0