Extending behaviour of activiti

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2016 01:24 PM
Hi,
I am trying to extend behaviour of Activiti in a Spring based activiti application.
So created interface extending your interface. For eg:
MyRepositoryService extends RepositoryService{}.
And also created implementation class extending your corresponding implementation class. For eg:
MyRepositoryServiceImpl extends RepositoryServiceImpl implements MyRepositoryService{}
My activiti-context file is
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns
="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.2.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.fingress.*">
<!– <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
–> </context:component-scan>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/fingresstest" />
<property name="username" value="root" />
<property name="password" value="password" />
</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" />
<property name="deploymentResources"
value="classpath*:/org/activiti/spring/test/autodeployment/autodeploy.*.bpmn20.xml" />
</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>
But when i try to deploy a process, i am getting null pointer exception in the below line of RepositoryServiceImpl class. "commandExecutor" seems to be null
public Deployment deploy(DeploymentBuilderImpl deploymentBuilder) {
return commandExecutor.execute(new DeployCmd<Deployment>(deploymentBuilder));
}
I am trying to extend behaviour of Activiti in a Spring based activiti application.
So created interface extending your interface. For eg:
MyRepositoryService extends RepositoryService{}.
And also created implementation class extending your corresponding implementation class. For eg:
MyRepositoryServiceImpl extends RepositoryServiceImpl implements MyRepositoryService{}
My activiti-context file is
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns

xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.2.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.fingress.*">
<!– <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
–> </context:component-scan>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/fingresstest" />
<property name="username" value="root" />
<property name="password" value="password" />
</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" />
<property name="deploymentResources"
value="classpath*:/org/activiti/spring/test/autodeployment/autodeploy.*.bpmn20.xml" />
</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>
But when i try to deploy a process, i am getting null pointer exception in the below line of RepositoryServiceImpl class. "commandExecutor" seems to be null
public Deployment deploy(DeploymentBuilderImpl deploymentBuilder) {
return commandExecutor.execute(new DeployCmd<Deployment>(deploymentBuilder));
}
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2016 12:59 PM
Can't really see it in the XML,but did you inject your new service into the ProcessEngineConfiguration?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2016 01:44 AM
Hi,
Thanks for responding. Please see attached XML configuration.
Thanks for responding. Please see attached XML configuration.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2016 02:42 AM
Hi,
I created Java configuration file too.
<java>
package com.fingress.workflow.configuration;
import javax.sql.DataSource;
import org.activiti.engine.impl.cfg.CommandExecutorImpl;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.spring.ProcessEngineFactoryBean;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
import org.springframework.transaction.PlatformTransactionManager;
import com.fingress.workflow.api.FgRepositoryService;
import com.fingress.workflow.api.impl.FgRepositoryServiceImpl;
@Configuration
@ComponentScan(basePackages = {"com.fingress.workflow.*"})
public class WorkflowConfiguration {
protected Resource[] processResources() {
return new Resource[] { new ClassPathResource("processes/*.bpmn20.xml") };
}
protected String databaseUrl() {
return "jdbc:h2:tcp://localhost/~/activiti_example4";
}
@Bean
public DataSource activitiDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/fingresstest");
dataSource.setUsername("root");
dataSource.setPassword("password");
return dataSource;
}
@Bean
public DataSource dataSource() {
return new TransactionAwareDataSourceProxy(activitiDataSource());
}
@Bean
public PlatformTransactionManager platformTransactionManager() {
return new DataSourceTransactionManager(this.dataSource());
}
@Bean
public FgRepositoryService repositoryService(){
return new FgRepositoryServiceImpl();
}
@Bean
public ProcessEngineFactoryBean processEngineFactoryBean() {
ProcessEngineFactoryBean pe = new ProcessEngineFactoryBean();
SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
processEngineConfiguration.setDataSource(this.dataSource());
processEngineConfiguration.setTransactionManager(this.platformTransactionManager());
processEngineConfiguration.setDatabaseSchemaUpdate(SpringProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
processEngineConfiguration.setRepositoryService(this.repositoryService());
Resource[] resources = processResources();
// processEngineConfiguration.setDeploymentResources(resources);
pe.setProcessEngineConfiguration(processEngineConfiguration);
return pe;
}
}
</java>
When i try to call deploy() method, it is giving null pointer exception for <b>commandexecutor</b>. This is happening only when deploy() is called from <b>MyRepositoryService</b>. When activiti repositoryservice deploy method is called it works fine.
Mu <b>MyrepositoryService extends RepositoryServiceImpl</b>
I created Java configuration file too.
<java>
package com.fingress.workflow.configuration;
import javax.sql.DataSource;
import org.activiti.engine.impl.cfg.CommandExecutorImpl;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.spring.ProcessEngineFactoryBean;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
import org.springframework.transaction.PlatformTransactionManager;
import com.fingress.workflow.api.FgRepositoryService;
import com.fingress.workflow.api.impl.FgRepositoryServiceImpl;
@Configuration
@ComponentScan(basePackages = {"com.fingress.workflow.*"})
public class WorkflowConfiguration {
protected Resource[] processResources() {
return new Resource[] { new ClassPathResource("processes/*.bpmn20.xml") };
}
protected String databaseUrl() {
return "jdbc:h2:tcp://localhost/~/activiti_example4";
}
@Bean
public DataSource activitiDataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/fingresstest");
dataSource.setUsername("root");
dataSource.setPassword("password");
return dataSource;
}
@Bean
public DataSource dataSource() {
return new TransactionAwareDataSourceProxy(activitiDataSource());
}
@Bean
public PlatformTransactionManager platformTransactionManager() {
return new DataSourceTransactionManager(this.dataSource());
}
@Bean
public FgRepositoryService repositoryService(){
return new FgRepositoryServiceImpl();
}
@Bean
public ProcessEngineFactoryBean processEngineFactoryBean() {
ProcessEngineFactoryBean pe = new ProcessEngineFactoryBean();
SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
processEngineConfiguration.setDataSource(this.dataSource());
processEngineConfiguration.setTransactionManager(this.platformTransactionManager());
processEngineConfiguration.setDatabaseSchemaUpdate(SpringProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
processEngineConfiguration.setRepositoryService(this.repositoryService());
Resource[] resources = processResources();
// processEngineConfiguration.setDeploymentResources(resources);
pe.setProcessEngineConfiguration(processEngineConfiguration);
return pe;
}
}
</java>
When i try to call deploy() method, it is giving null pointer exception for <b>commandexecutor</b>. This is happening only when deploy() is called from <b>MyRepositoryService</b>. When activiti repositoryservice deploy method is called it works fine.
Mu <b>MyrepositoryService extends RepositoryServiceImpl</b>
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2016 05:50 AM
You need to inject your service into the processEngineConfiguration bean too.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2016 05:27 AM
Hi,
I did inject as shown below. But still got the same error.
<java>
public SpringProcessEngineConfiguration springProcessEngineConfiguration() {
SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
processEngineConfiguration.setDataSource(this.dataSource());
processEngineConfiguration.setTransactionManager(this.platformTransactionManager());
processEngineConfiguration.setDatabaseSchemaUpdate(SpringProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
processEngineConfiguration.setRepositoryService(this.repositoryService());
</java>
<java>
@Bean
public FgRepositoryService repositoryService(){
return new FgRepositoryServiceImpl();
}
</java>
I did inject as shown below. But still got the same error.
<java>
public SpringProcessEngineConfiguration springProcessEngineConfiguration() {
SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
processEngineConfiguration.setDataSource(this.dataSource());
processEngineConfiguration.setTransactionManager(this.platformTransactionManager());
processEngineConfiguration.setDatabaseSchemaUpdate(SpringProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
processEngineConfiguration.setRepositoryService(this.repositoryService());
</java>
<java>
@Bean
public FgRepositoryService repositoryService(){
return new FgRepositoryServiceImpl();
}
</java>
