工作流Activiti异常积累

上一篇:Spring学习之整合Activiti(三)之Id生成

1、部署时生成流程图异常:Could not load image for process diagram creation: Can't create cache file

Activiti在Linux系统上部署流程时报以下错误:

[org.activiti.image.impl.DefaultProcessDiagramCanvas.initialize(DefaultProcessDiagramCanvas.java:245)]
Could not load image for process diagram creation: Can't create cache file!
 [WARN ][2019/01/09 18:06:06346][org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:160)]
Error while generating process diagram, image will not be stored in repository
 java.lang.NullPointerException
    at org.activiti.image.impl.DefaultProcessDiagramCanvas.drawTask(DefaultProcessDiagramCanvas.java:663)
    at org.activiti.image.impl.DefaultProcessDiagramCanvas.drawUserTask(DefaultProcessDiagramCanvas.java:826)
    at org.activiti.image.impl.DefaultProcessDiagramGenerator$6.draw(DefaultProcessDiagramGenerator.java:185)
    at org.activiti.image.impl.DefaultProcessDiagramGenerator.drawActivity(DefaultProcessDiagramGenerator.java:587)
    at org.activiti.image.impl.DefaultProcessDiagramGenerator.generateProcessDiagram(DefaultProcessDiagramGenerator.java:494)
    at org.activiti.image.impl.DefaultProcessDiagramGenerator.generateDiagram(DefaultProcessDiagramGenerator.java:403)
    at org.activiti.image.impl.DefaultProcessDiagramGenerator.generateDiagram(DefaultProcessDiagramGenerator.java:425)
    at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:155)
    at org.activiti.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:58)
    at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:106)
    at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:37)
    at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
    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.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:79)
    at org.activiti.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:156)
    at net.northking.service.impl.activiti.ModelServiceImpl.deploy(ModelServiceImpl.java:76)
    at net.northking.controller.activiti.ModelController.deployByModelId(ModelController.java:171)
    at net.northking.controller.activiti.ModelController.deploy(ModelController.java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

并且生成流程图失败,从报错信息可以看到是DefaultProcessDiagramCanvas.java的663行导致,进去后(位于activiti-image-generator-5.22.0.jar包的org.activiti.image.impl下)发现这是这行报空指针:

method_drawTask.png

从这里不难猜测是icon为空,再查找该方法的引用处:drawUserTask方法:

method_drawUserTask.png

再看USERTASK_IMAGE的赋值的地方:

method_initialize.png

可以看到正是这里抛出的异常,错误信息是 Can't create cache file!查看ImageIO源代码发现其中使用了一个缓冲区,在使用ImageIO进行图片读写操作时,Linux默认会使用缓存目录:${tomcat}/temp,在此缓存目录会生成缓存文件imageio4138671232726624650.tmp(这一串数字应该是当前时间戳,临时文件名),有些生产或测试环境的tomcat,会将temp目录删除,因此报错Can't create cache file! 其实已经说得很明显,缓冲区文件无法创建,找到缓冲区目录看一下即可找到原因,目录不存在、目录不可写等等。

4种解决方法如下

  1. 在tomcat下新建temp目录;

  2. 与方法1相似,通过ImageIO.setCacheDirectory(cacheDirectory);设置任意的、存在的缓存目录

  3. ImageIO默认是使用缓存目录,可以通过ImageIO.setUseCache(false)来设置,更改缓存策略,不使用文件目录缓存,使用内存缓存

  4. 不使用ImageIO,换成其它JDK方法
    ImageIO.write(bi, "jpg", baos);
    换成:
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
    encoder.encode(image);

解决方案摘自:https://blog.csdn.net/cwfreebird/article/details/51820993

2、ActivitiWrongDbException: version mismatch: activiti library version is '5.22.0.0', db version is null Hint

Activiti配置时,导入数据表的创建sql文件后,启动项目,报以下错误:

Caused by: org.activiti.engine.ActivitiWrongDbException: version mismatch: activiti library version is '5.22.0.0', db version is null Hint: Set (ProcessEngineImpl.java:80)
    at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:613)
    at org.activiti.spring.SpringProcessEngineConfiguration.buildProcessEngine(SpringProcessEngineConfiguration.java:65)
    at org.activiti.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:60)
    at org.activiti.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:32)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
    ... 41 more

这个是由于数据库内的版本跟实际的版本不匹配导致的(ACT_GE_PROPERTY表),我这是由于导数据的时候该表数据部分未导入成功,导致一直报改错误,我的pom.xml中的activiti 版本为 5.22.0.0,而是数据表ACT_GE_PROPERTY中为null:

image.png

该表插入以下数据即可。

INSERT INTO `act_ge_property` VALUES ('next.dbid', '1', 1);
INSERT INTO `act_ge_property` VALUES ('schema.history', 'create(5.22.0.0)', '1');
INSERT INTO `act_ge_property` VALUES ('schema.version', '5.22.0.0', '1');

其中的5.22.00与pom.xml中的activiti的版本保持一致。
sql表数据如下:

image.png

3、no resource found with name '需求提交流程模型.requirementConfirmProcess.png' in deployment '180001'

现象:点击流程图,图片加载失败,后台日志为:

 org.activiti.engine.ActivitiObjectNotFoundException: no resource found with name '需求提交流程模型.requirementConfirmProcess.png' in deployment '180001'
    at org.activiti.engine.impl.cmd.GetDeploymentResourceCmd.execute(GetDeploymentResourceCmd.java:58)
    at org.activiti.engine.impl.cmd.GetDeploymentResourceCmd.execute(GetDeploymentResourceCmd.java:30)
    at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
    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.RepositoryServiceImpl.getResourceAsStream(RepositoryServiceImpl.java:113)
    at net.northking.activiti.service.ProcessService.getDiagramByProDefinitionId_noTrace(ProcessService.java:435)
    at net.northking.activiti.controller.ProcessController.loadByDeployment(ProcessController.java:749)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

调用方法 net.northking.activiti.service.ProcessService.javagetDiagramByProDefinitionId_noTrace方法:

public InputStream getDiagramByProDefinitionId_noTrace(String resourceType, String deploymentId) throws Exception {
        ProcessDefinition processDefinition = findProcessDefinitionByDeploymentId(deploymentId);
        String resourceName = "";
        if (resourceType.equals("png") || resourceType.equals("image")) {
            resourceName = processDefinition.getDiagramResourceName();
        } else if (resourceType.equals("xml")) {
            resourceName = processDefinition.getResourceName();
        }
        InputStream resourceAsStream = null;
        if (StringUtil.isNotEmpty(resourceName)) {
            resourceAsStream = repositoryService.getResourceAsStream(deploymentId, resourceName);
        }
        return resourceAsStream;
    }

继续往下走,org.activiti.engine.impl.RepositoryServiceImpl.java

  public InputStream getResourceAsStream(String deploymentId, String resourceName) {
    return commandExecutor.execute(new GetDeploymentResourceCmd(deploymentId, resourceName));
  }
  

最后在org.activiti.engine.impl.cmd.GetDeploymentResourceCmd.java的execute方法抛出异常:

  public InputStream execute(CommandContext commandContext) {
    if (deploymentId == null) {
      throw new ActivitiIllegalArgumentException("deploymentId is null");
    }
    if(resourceName == null) {
      throw new ActivitiIllegalArgumentException("resourceName is null");
    }
    
    ResourceEntity resource = commandContext
      .getResourceEntityManager()
      .findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);
    if(resource == null) {
      if(commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId) == null) {
        throw new ActivitiObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class);
      }
      else
      {
        throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", InputStream.class);
      }
    }
    return new ByteArrayInputStream(resource.getBytes());
  }

场景重现并分析:(可以在这时,即先启动服务,再执行init流程模型相关sql文件)在数据库已有流程且未部署,且act_ge_property表中的next.dbid为180001;如下图:

image.png

(也可以在这时,启动服务,再部署流程,如果前一个步骤执行完毕没有操作过流程则不用在此处重启服务)部署(任何)一个流程,此时该流程的部署id一定为180001(不清楚原因的话可以详看 上一篇:Spring学习之整合Activiti(三)之Id生成 ),并会往act_ge_bytearray表插入两条180002、180003的数据:

image.png

然后执行一个新增流程的sql文件:

image.png

执行完成后数据表如下:

image.png

可以看到act_ge_bytearray中,新增流程模型的180002、180003覆盖了之前部署的流程的180002、180003信息,所以导致获取act_ge_bytearray之前的180002、180003流程信息为null,故抛错

4、deployment '180001' didn't put process definition 'requirementConfirmProcess:1:180004' in the cache

现象:启动流程或获取流程追踪图失败,后台日志为:

Caused by: org.activiti.engine.ActivitiException: deployment '180001' didn't put process definition 'requirementConfirmProcess:1:180004' in the cache
    at org.activiti.engine.impl.persistence.deploy.DeploymentManager.resolveProcessDefinition(DeploymentManager.java:189)
    at org.activiti.engine.impl.persistence.deploy.DeploymentManager.findDeployedProcessDefinitionById(DeploymentManager.java:77)
    at org.activiti.engine.impl.cmd.GetDeploymentProcessDefinitionCmd.execute(GetDeploymentProcessDefinitionCmd.java:39)
    at org.activiti.engine.impl.cmd.GetDeploymentProcessDefinitionCmd.execute(GetDeploymentProcessDefinitionCmd.java:26)
    at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
    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.RepositoryServiceImpl.getDeployedProcessDefinition(RepositoryServiceImpl.java:139)
    at net.northking.activiti.util.ProcessDefinitionCache.getProcessDefination(ProcessDefinitionCache.java:81)
    at net.northking.activiti.service.ProcessService.getActivitiProccessImage(ProcessService.java:464)
    ... 42 more

启动流程和获取流程追踪图都是在net.northking.activiti.util.ProcessDefinitionCache.java的getProcessDefination方法抛错,该方法代码为:

    public ProcessDefinition getProcessDefination(String processDefinitionId) {
        ProcessDefinition processDefinition = map.get(processDefinitionId);

        if (processDefinition == null) {
            if (null == repositoryService) {
                repositoryService = ApplicationContextHandler.getBean(RepositoryService.class);
            }
            processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService)
                    .getDeployedProcessDefinition(processDefinitionId);
            if (processDefinition != null) {
                put(processDefinitionId, processDefinition);
            }
        }
        return processDefinition;
    }

跟踪代码,可以看到,抛错的地方为:
org.activiti.engine.impl.persistence.deploy.DeploymentManager.java中的resolveProcessDefinition方法:

  public ProcessDefinitionEntity resolveProcessDefinition(ProcessDefinitionEntity processDefinition) {
    String processDefinitionId = processDefinition.getId();
    String deploymentId = processDefinition.getDeploymentId();
    processDefinition = processDefinitionCache.get(processDefinitionId);
    if (processDefinition==null) {
      DeploymentEntity deployment = Context
        .getCommandContext()
        .getDeploymentEntityManager()
        .findDeploymentById(deploymentId);
      deployment.setNew(false);
      deploy(deployment, null);
      processDefinition = processDefinitionCache.get(processDefinitionId);
      
      if (processDefinition==null) {
        throw new ActivitiException("deployment '"+deploymentId+"' didn't put process definition '"+processDefinitionId+"' in the cache");
      }
    }
    return processDefinition;
  }
  

场景重现及分析:
场景类似问题3
1、部署已有流程,
2、然后运行新增流程模型的sql文件,
3、重启服务(或者先重启再运行新增流程模型的sql文件);
4、启动已部署的流程,报:

 org.activiti.engine.ActivitiException: deployment '180001' didn't put process definition 'requirementConfirmProcess:1:180004' in the cache
    at org.activiti.engine.impl.persistence.deploy.DeploymentManager.resolveProcessDefinition(DeploymentManager.java:189)
    at org.activiti.engine.impl.persistence.deploy.DeploymentManager.findDeployedProcessDefinitionById(DeploymentManager.java:77)
    at org.activiti.engine.impl.cmd.GetDeploymentProcessDefinitionCmd.execute(GetDeploymentProcessDefinitionCmd.java:39)
    at org.activiti.engine.impl.cmd.GetDeploymentProcessDefinitionCmd.execute(GetDeploymentProcessDefinitionCmd.java:26)
    at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
    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.RepositoryServiceImpl.getDeployedProcessDefinition(RepositoryServiceImpl.java:139)
    at net.northking.activiti.util.ProcessDefinitionCache.getProcessDefination(ProcessDefinitionCache.java:81)
    at net.northking.activiti.util.ProcessDefinitionCache.getActivities(ProcessDefinitionCache.java:108)
    at net.northking.activiti.service.CusUserTaskService.initSingleActivitiInfo(CusUserTaskService.java:79)
    at net.northking.activiti.service.CusUserTaskService.initProcessUserTaskInfo(CusUserTaskService.java:64)
    at net.northking.activiti.controller.ProcessController.initUserTaskAssignees(ProcessController.java:415)
    at net.northking.activiti.controller.ProcessController.startProcess(ProcessController.java:376)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

解决方案
目前的解决方法是:
1、在每插入一条新的流程模型时,先判断其字段EDITOR_SOURCE_VALUE_ID_(即为act_ge_bytearray中的ID_ 值)和EDITOR_SOURCE_EXTRA_VALUE_ID_(即为act_ge_bytearray中的ID_ 值) 在表 act_ge_bytearray中是否存在(因为不能直接更新外键,所以该操作需要去除外键),
存在的条件是ID_NAME_都相等:
如果只有ID_相等的话,则ID_的值+3000(这个值是我估算的),代码如下:


/* 当数据表act_ge_bytearray中已有主键但`NAME_` != 'source-extra'时,修改待插入数据的`ID_`为value(`ID_`)+3000*/

INSERT INTO `act_re_model` VALUES
('180001', '5', '项目变更流程模型', '180001', null, '2019-05-17 12:16:30.980', '2019-05-27 16:43:06.448', '1','{\"name\":\"项目变更流程模型\",\"revision\":1,\"description\":\"项目变更流程:\\n申请人发起变更,科技项目经理进行确认,确认不通过则退回至发起人,通过后流向pmo初审;\\npmo审批:驳回则退回到项目经理确认节点,通过则再判断条件:非重大项目 and 非重大变更 and 变更类型 等于 计划变更都成立时,归档并结束流程;条件不成立则启动oa系统中的流程,挂起当前流程,待oa系统的流程通过后回到当前流程,激活流程,判断是否为需求变更,不是的话直接归档当前流程;是需求变更的话,进行需求分析,分析驳回后退回到pmo初审,分析通过后进行需求分析确认节点,确认通过后流程归档。\"}', null, 
        (SELECT (case when (EXISTS (SELECT `ID_` FROM `act_ge_bytearray`  WHERE `ID_`='180002' AND `NAME_` != 'source'))
                    then '183002'
                    else '180002' 
                end) 
        FROM `act_ge_bytearray` limit 1),
        (SELECT (case when (EXISTS (SELECT `ID_` FROM `act_ge_bytearray`  WHERE `ID_`='180003' AND `NAME_` != 'source-extra'))
                    then '183003'
                    else '180003' 
                end) 
        FROM `act_ge_bytearray` limit 1),
        '')
ON DUPLICATE KEY UPDATE `REV_`=VALUES(`REV_`),`NAME_`=VALUES(`NAME_`),`KEY_`=VALUES(`KEY_`),`CATEGORY_`=VALUES(`CATEGORY_`),`CREATE_TIME_`=VALUES(`CREATE_TIME_`),`LAST_UPDATE_TIME_`=VALUES(`LAST_UPDATE_TIME_`),`VERSION_`=VALUES(`VERSION_`),`META_INFO_`=VALUES(`META_INFO_`),`DEPLOYMENT_ID_`=VALUES(`DEPLOYMENT_ID_`),`EDITOR_SOURCE_VALUE_ID_`=VALUES(`EDITOR_SOURCE_VALUE_ID_`),`EDITOR_SOURCE_EXTRA_VALUE_ID_`=VALUES(`EDITOR_SOURCE_EXTRA_VALUE_ID_`),`TENANT_ID_`=VALUES(`TENANT_ID_`);

2、删除act_ge_bytearray已有数据

DELETE FROM `act_ge_bytearray` WHERE `ID_`='180002' AND `NAME_` = 'source';
DELETE FROM `act_ge_bytearray` WHERE `ID_`='180003' AND `NAME_` = 'source-extra';

3、插入新数据,ID_act_re_model表的EDITOR_SOURCE_VALUE_ID_值和EDITOR_SOURCE_EXTRA_VALUE_ID_

image.png

去除外键的sql为:

ALTER TABLE `act_re_model`
DROP foreign key `ACT_FK_MODEL_SOURCE`;
ALTER TABLE `act_re_model`
DROP foreign key `ACT_FK_MODEL_SOURCE_EXTRA`;
ALTER TABLE `act_re_model`
DROP index `ACT_FK_MODEL_SOURCE`;
ALTER TABLE `act_re_model`
DROP index `ACT_FK_MODEL_SOURCE_EXTRA`;

上一篇:Spring学习之整合Activiti(三)之Id生成

你可能感兴趣的:(工作流Activiti异常积累)