cancel
Showing results for 
Search instead for 
Did you mean: 

Simplest possible Spring integration

awagner99
Champ in-the-making
Champ in-the-making
Hi all,

I'm new to activiti, trying to integrate it into a simple spring MVC app, and I'm missing something. I'm trying to do the simplest possible thing, keeping everything in memory. Here's everything I've done:

pom.xml
+               <dependency>
+                   <groupId>org.activiti</groupId>
+                       <artifactId>activiti-spring</artifactId>
+                       <version>5.13</version>
+               </dependency> 

DomainObject.java
+       @Autowired
+       private RuntimeService runtimeService;

+               runtimeService.startProcessInstanceByKey("vacationRequest", variables);
+                    
+               logger.info("Number of process instances: " + runtimeService.createProcessInstanceQuery().count());

applicationContext.xml
+       <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration"/>
+      
+       <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
+               <property name="processEngineConfiguration" ref="processEngineConfiguration" />
+       </bean>
+
+       <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />

servlet-context.xml
+       <context:component-scan base-package="org.activiti"/>

The error that I'm getting is a classic:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.activiti.engine.RuntimeService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


I've tried a lot of different combinations of things, but this seems like the simplest possible thing that should work. What am I missing?
4 REPLIES 4

awagner99
Champ in-the-making
Champ in-the-making
Wow. That formatted terribly. Let me try again:

Hi all,

I'm new to activiti, trying to integrate it into a simple spring MVC app, and I'm missing something. I'm trying to do the simplest possible thing, keeping everything in memory. Here's everything I've done:

pom.xml
+               <dependency>
+                   <groupId>org.activiti</groupId>
+                       <artifactId>activiti-spring</artifactId>
+                       <version>5.13</version>
+               </dependency> 

DomainObject.java
+       @Autowired
+       private RuntimeService runtimeService;

+               runtimeService.startProcessInstanceByKey("vacationRequest", variables);
+                    
+               logger.info("Number of process instances: " + runtimeService.createProcessInstanceQuery().count());

applicationContext.xml
+       <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration"/>
+      
+       <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
+               <property name="processEngineConfiguration" ref="processEngineConfiguration" />
+       </bean>
+
+       <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />

servlet-context.xml
+       <context:component-scan base-package="org.activiti"/>

The error that I'm getting is a classic:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.activiti.engine.RuntimeService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


I've tried a lot of different combinations of things, but this seems like the simplest possible thing that should work. What am I missing?

frederikherema1
Star Contributor
Star Contributor
this seems to be more of a configuration issue than a specific activiti issue. The class you're using, that has the @Autowire isn't using the correct application-context, so it seems. Can you inject the ProcessEngine, instead of the services separately?

fnoorie
Champ in-the-making
Champ in-the-making
I am facing the exact issue. I tried autowiring the processEngine in my Service Impl but now I get

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.activiti.engine.ProcessEngine com.paypal.pricing.service.core.PricingServImpl.processEngine; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.activiti.engine.ProcessEngine] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I agree with Frederik, it seems like configuration issue. Could you share your project?

Regards
Martin