jbpm创建公文出现异常

eyouas 2010-07-20 09:23:02
processdefinition.xml
<?xml version="1.0" encoding="UTF-8"?>

<process-definition
xmlns="" name="test1">
<start-state name="start">
<transition name="" to="张三审批"></transition>
</start-state>
<task-node name="张三审批">
<task name="张三审批">
<assignment actor-id="张三"/>
</task>
<transition name="" to="李四审批"></transition>
</task-node>
<task-node name="李四审批">
<task name="李四审批">
<assignment actor-id="李四"/>
</task>
<transition name="" to="王五审批"></transition>
</task-node>
<task-node name="王五审批">
<task name="王五审批">
<assignment actor-id="王五"/>
</task>
<transition name="" to="end1"></transition>
</task-node>
<end-state name="end1"></end-state>
</process-definition>




//创建表
public void test(){
JbpmConfiguration.getInstance().createSchema();
}

//创建对象
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("jbpm.cfg.xml");

public void test()
{

JbpmContext context = jbpmConfiguration.createJbpmContext();

ProcessDefinition def = ProcessDefinition.parseXmlResource("test1/processdefinition.xml");


try {
context.deployProcessDefinition(def);
} catch (Exception e) {
e.printStackTrace();
context.setRollbackOnly();
}finally{context.close();}
}





static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
//创建公文
public void test()
{
JbpmContext context = jbpmConfiguration.createJbpmContext();

try {
Document doc = new Document();
doc.setTitle("*****测试TEST: "+ new Random().nextInt(999));
context.getSession().save(doc);
ProcessDefinition def =null;
GraphSession graphSession = context.getGraphSession();
try {
graphSession.findLatestProcessDefinition("test1");
} catch (Exception e) {
System.out.println("没找到");
}

ProcessInstance instance = new ProcessInstance(def);
context.save(instance);
long a=instance.getId();
int id=(int)a;
doc.setProcessInstanceId(id);
instance.getContextInstance().setVariable("document", doc.getId());

} catch (Exception e) {
e.printStackTrace();
context.setRollbackOnly();
}finally{context.close();}

}


创建表,创建流程实例正常,创建公文出现经下异常:
java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:749)
at org.jbpm.db.GraphSession.findLatestProcessDefinition(GraphSession.java:153)
at com.accp.vo.CreateDocument.test(CreateDocument.java:28)
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)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
org.jbpm.JbpmException: can't create a process instance when processDefinition is null没找到

at org.jbpm.graph.exe.ProcessInstance.<init>(ProcessInstance.java:128)
at org.jbpm.graph.exe.ProcessInstance.<init>(ProcessInstance.java:92)
at com.accp.vo.CreateDocument.test(CreateDocument.java:33)
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)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
异常打印说明了,查找不到流程实例对象,请教?
...全文
91 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
edit888888 2010-08-25
  • 打赏
  • 举报
回复
static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
//创建公文
public void test()
{
JbpmContext context = jbpmConfiguration.createJbpmContext();

try {
Document doc = new Document();
doc.setTitle("*****测试TEST: "+ new Random().nextInt(999));
context.getSession().save(doc);
ProcessDefinition def =null;
GraphSession graphSession = context.getGraphSession();
try {
graphSession.findLatestProcessDefinition("test1");
} catch (Exception e) {
System.out.println("没找到");
}

ProcessInstance instance = new ProcessInstance(def);
context.save(instance);
long a=instance.getId();
int id=(int)a;
doc.setProcessInstanceId(id);
instance.getContextInstance().setVariable("document", doc.getId());

} catch (Exception e) {
e.printStackTrace();
context.setRollbackOnly();
}finally{context.close();}

}


初级错误,没有把找到的ProcessDefinition 赋值给def.理所当然会找不到流程定义.
dfyoumu 2010-07-26
  • 打赏
  • 举报
回复
重新建表,重新生成流程实例
eyouas 2010-07-20
  • 打赏
  • 举报
回复
谢谢回答,任务的参与者已经配好了,现在问题主要是,创建不了公文 ,再次再教
landyshouguo 2010-07-20
  • 打赏
  • 举报
回复
你在任务的参与者里面配了没...Handle...actor
牛叔 2010-07-20
  • 打赏
  • 举报
回复
没做过工作流
友情帮顶
eyouas 2010-07-20
  • 打赏
  • 举报
回复
谢谢上面的回答,流程已经发布了,数据库表中已存在了流程记录
mycity21 2010-07-20
  • 打赏
  • 举报
回复
是不是未发布流程
eyouas 2010-07-20
  • 打赏
  • 举报
回复
有高手帮忙吗?在线等待
tangyuanzhou 2010-07-20
  • 打赏
  • 举报
回复
唐元舟 非常好,加分

67,541

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧