完整工作流JBPM项目实战全过程教程4----关于Spring整合jbpm时页面显示流程图出错处理
???? 在原来项目的基础上来实现流程图动态显示的功能,发现利用JBPM自己写的标签会报错,原因是项目是用Spring整合JBPM的,当引用标签的时候,标签中的处理函数调用JbpmContext就会发生Hibernate 方言错误。
???? 那如何来处理该错误呢?google了一下,发现了一篇不错的文章,就讲到了这个问题。
??? 下面我就把关键的部分引用过来,当然为了支持原创,我把地址附上
?http://hi.baidu.com/xiaolangs/blog/item/ea0625fb1d3ff061034f5685.html
??????? WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getSession().getServletContext());
??????? JbpmTemplate jbpmTemplate = (JbpmTemplate) wac.getBean("jbpmTemplate");
??????? jbpmTemplate.execute(new JbpmCallback() {
??????????? public Object doInJbpm(JbpmContext context) {
??????????????? processDefinition = context.getGraphSession().loadProcessDefinition(processDefinitionId);
??????????????? bytes = processDefinition.getFileDefinition().getBytes("processimage.jpg");
??????????????? return null;
??????????? }
??????? });
??????? OutputStream out = response.getOutputStream();
??????? out.write(bytes);
??????? out.flush();
??? }
}
问题二
如果你的流程是用中文字符,且数据库字符集为utf-8,再数据库中为正确的utf-8内容,也可能会乱码错误。
如:我的数据库里的gpd.xml

出错的类:ProcessImageTag.java
出错行:result[0] = Integer.valueOf(node.attribute("x").getValue());
如果此地为nullpoint错误,是因为上下文的Element root中的字符为乱码。
修改:
原代码:Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes)).getRootElement();
修改后:Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes, "utf-8")).getRootElement();
说明:有个地方要注意,<jbpm:processimage task="${taskBean.taskInstanceId}"/> 显示图片是以当前的路径为基础的。style="background-image:url(processimage?definitionId=1)",也就是说当页面为:http://localhost/jbpm/workflow/showTaskInstance.jsp时,你所访问的流程图地址为:http://localhost/jbpm/workflow/processimage?definitionId=1,这个地址是错误的,实际地址为:http://localhost/jbpm/processimage?definitionId=1,要正确显示需修改ProcessImageTag.java
原代码:background-image:url(" + imageLink + ");
修改后:background-image:url(" + ((HttpServletRequest) pageContext.getRequest()).getContextPath() + "/" + imageLink + ");
OK,恭喜你成功显示JBPM流程图。
?
?
??? 嘿嘿,还真管用,流程图显示OK了。后续我会把DIY后的项目源码再上传一份供参考。
1 楼 flyfan 2008-11-06 一直在关注,给个图就更好了,断续期待,加油 2 楼 zoutuo 2009-06-26 严重: Servlet.service() for servlet jsp threw exception