activiti工作流 ProcessEngines.getDefaultProcessEngine()为null

J2EE 码拜 10年前 (2015-04-04) 1891次浏览 0个评论
 

这是目录结构
activiti工作流 ProcessEngines.getDefaultProcessEngine()为null
这是activiti.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
	   					   http://www.springframework.org/schema/beans/spring-beans.xsd">
	<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
		<property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
		<property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/mydb" />
		<property name="jdbcUsername" value="root" />
		<property name="jdbcPassword" value="zxt0txz" />
		<property name="databaseSchemaUpdate" value="true" />
	</bean>	   					   
</beans>

这是bpmn文件

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask3"></sequenceFlow>
    <userTask id="usertask2" name="Handle Request"></userTask>
    <sequenceFlow id="flow2" sourceRef="usertask3" targetRef="usertask2"></sequenceFlow>
    <userTask id="usertask3" name="Expense Request"></userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="180.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="55.0" width="105.0" x="500.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55.0" width="105.0" x="300.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="740.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="215.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="300.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="405.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="500.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="605.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="740.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

这是流程调用类

package org.start.main;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

public class Main {
	public static void main(String[] args) {
		ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
		RepositoryService repositoryService = processEngine.getRepositoryService();
		RuntimeService runtimeService = processEngine.getRuntimeService();
		TaskService taskService = processEngine.getTaskService();
		repositoryService.createDeployment().addClasspathResource("bpmn/main.bpmn");
		runtimeService.startProcessInstanceById("myProcess");
		Task taskA = taskService.createTaskQuery().singleResult();
		System.out.println("第一个任务完成前,当前的任务名为:" + taskA.getName());
		taskService.complete(taskA.getId());
		Task taskB = taskService.createTaskQuery().singleResult();
		System.out.println("第二个任务完成前,当前任务名为:" + taskB.getName());
		taskService.complete(taskB.getId());
		Task taskC = taskService.createTaskQuery().singleResult();
		System.out.println("流程结束后,查找任务:" + taskC);
	}
}

这是报错

log4j:WARN No appenders could be found for logger (org.activiti.engine.ProcessEngines).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NullPointerException
	at org.start.main.Main.main(Main.java:13)
activiti工作流 ProcessEngines.getDefaultProcessEngine()为null
40分
是不是少了log4j包?或该包有版本冲突。
activiti工作流 ProcessEngines.getDefaultProcessEngine()为null
没有大神吗?
activiti工作流 ProcessEngines.getDefaultProcessEngine()为null
我怀疑是不是spring的版本高了?
activiti工作流 ProcessEngines.getDefaultProcessEngine()为null
引用 1 楼 zhangjihao 的回复:

是不是少了log4j包?或该包有版本冲突。

是log4j的配置文件我没加


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明activiti工作流 ProcessEngines.getDefaultProcessEngine()为null
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!