Bean creation for processRuntime in activitiConfiguration giving error.

cancel
Showing results for 
Search instead for 
Did you mean: 
vsehgal
Member II

Bean creation for processRuntime in activitiConfiguration giving error.

I have a class where I am trying to autowire processRuntime. The code is simple:
@Autowired
private ProcessRuntime processRuntime;
I need this object to start my workflow process. But my code fail with the following error:
required a bean of type 'org.activiti.api.process.runtime.ProcessRuntime' that could not be found.
How do I get the bean of processRuntime in my service.I created a bean for processRuntime in my activitiConfiguration using ProcessRuntimeImpl like this:
@bean
public ProcessRuntime processRuntime() throws Exception {
return new ProcessRuntimeImpl(getRepositoryService(), null, getRuntimeService(), getTaskService(), null,
new APIProcessInstanceConverter(), new APIVariableInstanceConverter(), new APIDeploymentConverter(), null, null, null, null);
}
where my constructor for ProcessRuntimeImpl has this definition:
public ProcessRuntimeImpl(RepositoryService repositoryService,
APIProcessDefinitionConverter processDefinitionConverter,
RuntimeService runtimeService,
TaskService taskService,
ProcessSecurityPoliciesManager securityPoliciesManager,
APIProcessInstanceConverter processInstanceConverter,
APIVariableInstanceConverter variableInstanceConverter,
APIDeploymentConverter deploymentConverter,
ProcessRuntimeConfiguration configuration,
ApplicationEventPublisher eventPublisher,
ProcessVariablesPayloadValidator processVariablesValidator,
SecurityManager securityManager) {
this.repositoryService = repositoryService;
this.processDefinitionConverter = processDefinitionConverter;
this.runtimeService = runtimeService;
this.taskService = taskService;
this.securityPoliciesManager = securityPoliciesManager;
this.processInstanceConverter = processInstanceConverter;
this.variableInstanceConverter = variableInstanceConverter;
this.deploymentConverter = deploymentConverter;
this.configuration = configuration;
this.eventPublisher = eventPublisher;
this.processVariablesValidator = processVariablesValidator;
this.securityManager = securityManager;
}
and was able to run my application, but while accessing the processes in the workflow, I got the following error:
java.lang.NullPointerException: Cannot invoke "org.activiti.api.runtime.shared.security.SecurityManager.getAuthenticatedUserId()" because "this.securityManager" is null
    at org.activiti.runtime.api.impl.ProcessRuntimeImpl.createProcessDefinitionQueryWithAccessCheck(ProcessRuntimeImpl.java:150)
    at org.activiti.runtime.api.impl.ProcessRuntimeImpl.processDefinition(ProcessRuntimeImpl.java:132)
    at org.activiti.runtime.api.impl.ProcessRuntimeImpl.getProcessDefinitionAndCheckUserHasRights(ProcessRuntimeImpl.java:498)
    at org.activiti.runtime.api.impl.ProcessRuntimeImpl.createProcessInstanceBuilder(ProcessRuntimeImpl.java:312)
    at org.activiti.runtime.api.impl.ProcessRuntimeImpl.start(ProcessRuntimeImpl.java:288)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
Now, I believe this issue is happening because while creating the bean for processRuntime using processRuntimeImpl, I passed the securityManager along with some other parameters as null. Can someone please help me in figuring out, how to create a bean for processRuntime? If creating a bean through processRuntimeImpl is the right way, can you please let us know, how to initialize the parameters for processRuntimeImpl constructor? If you can also share some working examples, that would be of great help. Thanks. I am working with the following alfresco dependency:
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring-boot-starter</artifactId>
<version>7.11.0</version>
</dependency>