NutzCN Logo
问答 activiti 启动流程 报错
发布于 31天前 作者 liumaobudao 138 次浏览 复制 上一个帖子 下一个帖子
标签: fireflow

代码

public Object addDo(@Param("..")Wf_oa_leave wfOaLeave, HttpServletRequest req) {
		try {
            Wf_oa_leave wf_oa_leave=  	wfOaLeaveService.insert(wfOaLeave);
            Subject subject = SecurityUtils.getSubject();
                Sys_user user = (Sys_user) subject.getPrincipal();
            identityService.setAuthenticatedUserId(user.getLoginname());
            Map<String, Object> variables = Maps.newHashMap();
            // 启动流程
            String businessKey = wf_oa_leave.getId().toString();
            variables.put("type", "leave");
            variables.put("busId", businessKey);
            variables.put("title", wf_oa_leave.getName());//设置标题;
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("leave", businessKey, variables);//

            // 更新流程实例ID
            wf_oa_leave.setProcessInstanceId(processInstance.getId());
            wfOaLeaveService.updateIgnoreNull(wf_oa_leave);

			return Result.success("system.success");
		} catch (Exception e) {
            e.printStackTrace();
			return Result.error("system.error");
		}
    }

报错

org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Unknown property used in expression: #{customTaskListener}
	at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:742)
	at org.activiti.engine.impl.persistence.entity.TaskEntity.setAssignee(TaskEntity.java:559)
	at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.handleAssignments(UserTaskActivityBehavior.java:241)
	at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.execute(UserTaskActivityBehavior.java:208)
	at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
	at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
	at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:650)
	at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:643)
	at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
	at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
	at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
	at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:650)
	at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:643)
	at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
	at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
	at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:650)
	at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:643)
	at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
	at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)

然后 看到 初始化的时候有加这个

    private void initActiviti(NutConfig config) {
        log.info("Activiti Init Start...");
        ProcessEngineConfigurationImpl processEngineConfiguration = config.getIoc().get(null, "processEngineSpec");

        // 使用系统角色及用户替换工作流的用户及用户组
        List<SessionFactory> list = new ArrayList<>();
        CustomGroupEntityManagerFactory customGroupManagerFactory = new CustomGroupEntityManagerFactory();
        customGroupManagerFactory.setGroupEntityManager(new CustomGroupEntityManager());
        CustomUserEntityManagerFactory customUserEntityManagerFactory = new CustomUserEntityManagerFactory();
        customUserEntityManagerFactory.setUserEntityManager(new CustomUserEntityManager());
        list.add(customGroupManagerFactory);
        list.add(customUserEntityManagerFactory);
        processEngineConfiguration.setCustomSessionFactories(list);
        //添加任务监听

        Map<Object, Object> beans = new HashMap<>();
        ProxyTaskListener proxyTaskListener = new ProxyTaskListener();
        List<TaskListener> taskListeners = new ArrayList<>();
        TaskCategoryTaskListener t1 = new TaskCategoryTaskListener();
        taskListeners.add(t1);
        proxyTaskListener.setTaskListeners(taskListeners);
        beans.put("customTaskListener", proxyTaskListener);//这里。。。
        processEngineConfiguration.setBeans(beans);
        List<BpmnParseHandler> customDefaultBpmnParseHandlers = new ArrayList<>();
        ProxyUserTaskBpmnParseHandler bpmnParseHandler = new ProxyUserTaskBpmnParseHandler();
        bpmnParseHandler.setUseDefaultUserTaskParser(true);
        bpmnParseHandler.setTaskListenerId("customTaskListener");
        customDefaultBpmnParseHandlers.add(bpmnParseHandler);
        processEngineConfiguration.setCustomDefaultBpmnParseHandlers(customDefaultBpmnParseHandlers);
        processEngineConfiguration.setBpmnParser(new CustomBpmnParser());
        //UUID
        processEngineConfiguration.setIdGenerator(new StrongUuidGenerator());
        ProcessEngine processEngine = config.getIoc().get(ProcessEngine.class);
        log.info("Activiti Init End::" + processEngine.getName());

    }
6 回复

记不清了,你确定什么都没改动?

@Wizzercn 初始化都是照搬的 ,没改 ,然后做外置表单启动流程。。。就报

org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Unknown property used in expression: #{customTaskListener}

老项目能正常跑么?如果老项目可以,那就仔细检查漏了什么~~

@Wizzercn

     //添加任务监听

        Map<Object, Object> beans = new HashMap<>();
        ProxyTaskListener proxyTaskListener = new ProxyTaskListener();
        List<TaskListener> taskListeners = new ArrayList<>();
        TaskCategoryTaskListener t1 = new TaskCategoryTaskListener();
        taskListeners.add(t1);
        proxyTaskListener.setTaskListeners(taskListeners);
        beans.put("customTaskListener", proxyTaskListener);//我就想知道 不设置 这个 可不可以    
        processEngineConfiguration.setBeans(beans);
        List<BpmnParseHandler> customDefaultBpmnParseHandlers = new ArrayList<>();
        ProxyUserTaskBpmnParseHandler bpmnParseHandler = new ProxyUserTaskBpmnParseHandler();
        bpmnParseHandler.setUseDefaultUserTaskParser(true);
        bpmnParseHandler.setTaskListenerId("customTaskListener");
        customDefaultBpmnParseHandlers.add(bpmnParseHandler);
        processEngineConfiguration.setCustomDefaultBpmnParseHandlers(customDefaultBpmnParseHandlers);
        processEngineConfiguration.setBpmnParser(new CustomBpmnParser());

你不需要的东西当然可以不设置啊...

@Wizzercn 100¥ 求个新版本 带请假流程的例子

添加回复
请先登陆
回到顶部