AnsweredAssumed Answered

Spring @Configuration with Activiti

Question asked by kebo on Feb 17, 2014
Latest reply on Feb 25, 2014 by jbarrez
Hi,
I'm new in activiti and I met problem with configuration activiti. I get null pointer when I want to load this configuration:


package org.workflow.config;

import org.activiti.engine.IdentityService;
import org.activiti.engine.RuntimeService;
import org.activiti.spring.ProcessEngineFactoryBean;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

@Configuration
public class ActivitiConfiguration {

   @Bean
   public BasicDataSource dataSource(){
      BasicDataSource dataSource = new BasicDataSource();
      dataSource.setDriverClassName("org.postgresql.Driver");
      dataSource.setUrl("jdbc:postgresql://localhost:5432/workflow");
      dataSource.setUsername("****");
      dataSource.setPassword("****");
      dataSource.setDefaultAutoCommit(false);
      
      return dataSource;
   }
   
   @Bean
   public DataSourceTransactionManager dataSourceTransactionManager(){
      DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager();
      dataSourceTransactionManager.setDataSource(dataSource());
      
      return dataSourceTransactionManager;
   }
   
   @Bean
   public SpringProcessEngineConfiguration processEngineConfiguration(){
      SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
      configuration.setDataSource(dataSource());
      configuration.setDatabaseType("postgresql");
      configuration.setTransactionManager(dataSourceTransactionManager());
      configuration.setDatabaseSchemaUpdate("true");
      configuration.setJobExecutorActivate(true);
      
      return configuration;
   }
   
   @Bean
   public ProcessEngineFactoryBean processEngineFactoryBean(){
      ProcessEngineFactoryBean bean = new ProcessEngineFactoryBean();
      bean.setProcessEngineConfiguration(processEngineConfiguration());
      
      return bean;
   }
   
   
   @Bean RuntimeService runtimeService(){
      return processEngineFactoryBean().getProcessEngineConfiguration().getRuntimeService();
   }
   
   @Bean
   public IdentityService identityService(){
      return processEngineFactoryBean().getProcessEngineConfiguration().getIdentityService();
   }
}


I build this configuration according to xml configuation. If you have any ideas please help me :)

Best regards

Outcomes