Camunda application not populating spring @components

I am starting my camunda application from different spring boot project as shown below. The process instance is started, but the beans are not initialized(i.e @Autowiring in BeanInjection delegate is null)

RestController call from different spring boot project:

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
log.debug("checkpoint2: "+processEngine.getName());

                                         if (processEngine != null) {
                                                        ProcessInstanceWithVariables instance = processEngine.getRuntimeService().createProcessInstanceByKey("version7")
                                                                         .setVariable("inHeader", header)
                                                                         // TODO change to inWorkOrder
                                                                         .setVariable("sampleObject",  sample)
                                                                         .executeWithVariablesInReturn();

And this is my java delegate which is a spring component having @Autowired field, which is not getting populated and is null

package com.wom_camunda_process;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

@Component
public class BeanInjection implements JavaDelegate {

@Autowired
BeanAutoWire beanAutoWire;



@Override
public void execute(DelegateExecution execution) throws Exception {
	// TODO Auto-generated method stub
	System.out.println("ENTER... BeanInjection");

beanAutoWire.printStatement();
}

}

In bpmn file specify the fully qualified class name in Class attribute or else in expression delegate specify like this:

${name of the bean}

In your case try expression delegate attribute: ${beanInjection}. If not works change @Component to @Component(value=“beanInjection”) and then specify expression delegate as : ${beanInjection}

Tried that but getting:

org.camunda.bpm.engine.ProcessEngineException: Unknown property used in expression: ${beanInjection}. Cause: Cannot resolve identifier ‘beanInjection’

This is my main application class with spring annotation

package com.wom_camunda_process;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ProcessApplication
@ComponentScan(basePackages= {“com.wom_camunda_process”})
public class CamundaApplication extends ServletProcessApplication{

private final static Logger log = LogManager.getLogger(CamundaApplication.class);

public static void main(String… args) {
SpringApplication.run(CamundaApplication.class, args);
}

}

Well, obviously you use an expression “${beanInjection}” in your bpmn model. Why? Spring is looking for a bean with that name but cannot find one. Wrong name? Forgot to annotate with @Component?

I have used @Component(value=“beanInjection”) in my java class.

Is it possible that there is a clash between @springbootapplication and @processapplication while process engine is started?

Hi aplakshmikanth,

I’m currently developing a tool that might help you. Check out vPAV and especially the JavaDelegateChecker, which tries to resolve your delegates or direct class references.

I’m guessing that either your class references are wrong or your bean mapping does not resolve properly to the delegate names provided in your model.

Cheers
Sascha