cancel
Showing results for 
Search instead for 
Did you mean: 

Spring MVC integration with activiti

hayot
Champ in-the-making
Champ in-the-making
Hi
I'm trying for 2 weeks to integrate activiti engine in my Spring MVC application without success.

Can anybody show me a simple working sample project, please! I need one simple project with everything configured. The configuration of beans are giving errors all the time. I truly appreciate if you could upload one zip file with working sample project.

This is my configuration files:

5 REPLIES 5

hayot
Champ in-the-making
Champ in-the-making
My activiti.cfg.xml file looks like ths
<code>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
                           http://www.springframework.org/schema/tx      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

  <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    <property name="driverClass" value="com.mysql.jdbc.Driver" />
    <property name="url" value="mysql://localhost:3306/activiti1?autoReconnect=true" />
    <property name="username" value="root" />
    <property name="password" value="root" />
  </bean>

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>
 
  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
   
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <!–  <property name="jobExecutorActivate" value="false" />–>
  </bean>
 
  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>
 
  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
  <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
  <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />

</beans>

</code>

hayot
Champ in-the-making
Champ in-the-making
And my simple controller is
<code>
@Controller
public class HomeController {

private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

private String filename = "NewProcess.bpmn20.bpmn";

//@Rule
//public ActivitiRule activitiRule = new ActivitiRule();




/**
  * Simply selects the home view to render by returning its name.
  * @throws FileNotFoundException
  */

@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) throws FileNotFoundException {
  logger.info("Welcome home! The client locale is {}.", locale);
 
   ApplicationContext context = new ClassPathXmlApplicationContext("activiti.cfg.xml");
  context.getAutowireCapableBeanFactory().autowireBean(this);
  ProcessEngine processEngine1 = (ProcessEngine)context.getBean("processEngine");
 
 
  List<Task> userAssignedTasks1 = processEngine1.getTaskService().createTaskQuery().list();
 
      
   model.addAttribute("per1", userAssignedTasks1);
       
  return "home";
}
    
        

}

</code>

frederikherema1
Star Contributor
Star Contributor
What error are you getting? Without an error, we can only guess…

hayot
Champ in-the-making
Champ in-the-making
this is an error
<code>
HTTP Status 500 - Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException
</code>

frederikherema1
Star Contributor
Star Contributor
Find out what the cause is of the null pointer and go from there. With a generic error-message without a stack trace, we can't help…