hustzhangj 发表于 2016-12-27 00:45:09

新人求助:不能用参数指定任务参与者

我的意图是用applyUserId表示当前发起流程者,用变量${deptLeaderId}指定部门领导,用变量${hrGroupId}指定人事审批参与组。
leave.bpmn20.xml的相关代码如下
<startEvent id="startevent1" name="开始" activiti:initiator="applyUserId"></startEvent>
    <userTask id="deptLeaderAudit" name="部门领导审批" activiti:assignee="${deptLeaderId}">
      <documentation>deptLeader.jsp</documentation>
    </userTask>
    ...
    <userTask id="hrAudit" name="人事审批" activiti:candidateGroups="${hrGroupId}">
      <documentation>hr.jsp</documentation>
    </userTask>
    ...
   
Java代码如下:
identityService.setAuthenticatedUserId(userId);//将用户ID设置到当前的线程中
Map<String,Object> variableMap = new HashMap<String,Object>();
variableMap.put("deptLeaderId","40284681575cbfbd01575cd505070012");
variableMap.put("hrGroupId","40284681575cbfbd01575cd21a18000c");
processInstance = this.runtimeService.startProcessInstanceById("leave:5:18713", businessKey, variableMap);

报错如下:
DEBUG- insert HistoricVariableInstanceEntity
DEBUG- insert HistoricVariableInstanceEntity
DEBUG- insert HistoricVariableInstanceEntity
00:28:09.577 DEBUG o.a.e.i.interceptor.CommandContext - Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.Cause: java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
### The error may involve org.activiti.engine.impl.persistence.entity.HistoricDetailEntity.bulkInsertHistoricDetailVariableInstanceUpdate-Inline
### The error occurred while setting parameters
### SQL: insert into ACT_HI_DETAIL (ID_, TYPE_, PROC_INST_ID_, EXECUTION_ID_, ACT_INST_ID_, TASK_ID_, NAME_, REV_, VAR_TYPE_, TIME_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT_, TEXT2_)   values                   (?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?)      ,          (?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?)      ,          (?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?,          ?)
### Cause: java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) ~
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147) ~
    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134) ~
    at org.activiti.engine.impl.db.DbSqlSession.flushBulkInsert(DbSqlSession.java:850) ~
    at org.activiti.engine.impl.db.DbSqlSession.flushPersistentObjects(DbSqlSession.java:820) ~
    at org.activiti.engine.impl.db.DbSqlSession.flushInserts(DbSqlSession.java:797) ~
    at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:618) ~
    at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212) ~
    at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:138) ~
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66)
    at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
    at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37)
    at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
    at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
    at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:118)
    at org.jeecgframework.web.activiti.service.impl.LeaveServiceImpl.leaveWorkFlowStart(LeaveServiceImpl.java:60)
    ...
Caused by: java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897) ~
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886) ~
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) ~
    at com.mysql.jdbc.PreparedStatement.setSerializableObject(PreparedStatement.java:3829) ~
    at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:3559) ~
    ... 75 common frames omitted
Caused by: java.io.NotSerializableException: org.activiti.engine.impl.variable.StringType
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164) ~
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330) ~
    at com.mysql.jdbc.PreparedStatement.setSerializableObject(PreparedStatement.java:3818) ~
    ... 99 common frames omitted
我用的环境是jdk1.6,mysql数据库,mysql-connector-java-5.1.40.jar驱动,activiti-engine-5.21.0版本。

这个问题困扰我好几天了,万能的互联网,请显灵吧!!!!

mcl77361 发表于 2017-5-1 23:47:30

是mybatis.version版本的问题。调整成3.2.5版本即可
页: [1]
查看完整版本: 新人求助:不能用参数指定任务参与者