AnsweredAssumed Answered

Why run Context.getCommandContex cause NullPointerException

Question asked by kafeitu on Nov 16, 2011
Latest reply on Nov 17, 2011 by kafeitu
these codes in method of Struts2 Action

TaskQuery taskQuery = taskService.createTaskQuery().processDefinitionKey("leave").taskCandidateUser(UserUtil.getCurrentUserId());
List<Task> tasks = taskQuery.listPage(0, 10);
for (Task task : tasks) {
   TaskEntity taskEntity = (TaskEntity) task;
   System.out.println(taskEntity.getIdentityLinks());
}

in applicationContext.xml:

<!– activiti begin –>
   <bean id="jdbcTransactionManager" 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="jdbcTransactionManager" />
      <property name="databaseSchemaUpdate" value="false" />
      <property name="jobExecutorActivate" value="false" />
      <property name="deploymentResources" value="classpath*:/com/wsria/demo/activiti/*.bpmn20.xml"></property>
   </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="formService" factory-bean="processEngine" factory-method="getFormService" />
   <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
   <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" />
   <!– activiti end –>

java.lang.NullPointerException
   at org.activiti.engine.impl.persistence.entity.TaskEntity.getIdentityLinks(TaskEntity.java:342)
   at com.wsria.demo.activiti.web.oa.leave.LeaveAction.runningList(LeaveAction.java:112)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
   at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
   at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
   at
        ………………

Outcomes