`
sliver08
  • 浏览: 9503 次
  • 性别: Icon_minigender_1
  • 来自: 福州
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

JBPM的JBPMContext对象延迟加载的问题

阅读更多
以下是我的一个action中的一个方法:
	
public ActionForward list(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		JbpmConfiguration configuration = Utils.configuration;
		JbpmContext jbpmContext = configuration.createJbpmContext();
		String userName = (String) request.getSession()
				.getAttribute("userName");
		try {
			TaskMgmtSession taskMgmtSession = jbpmContext.getTaskMgmtSession();
			List list = taskMgmtSession.findPooledTaskInstances(userName);
			request.setAttribute("list", list);
			return mapping.findForward("list");
		} finally {
			jbpmContext.close();//在这里把上下文关闭掉了,引起了页面出错		
}
	}

我在action中取得当前登陆用户的所有任务的list,将它放进request中转发到jsp,并显示.此时context已经关闭
jsp部分代码如下
    <table>
    	<tr>
    		<td>报销单ID</td>
    		<td>环节名称</td>
    		<td>建立时间</td>
    		<td>操作</td>
    	</tr>
    	<logic:iterate id="task" scope="request" name="list">
    	<tr>
    		<td><%=((TaskInstance) task).getVariable("baoxiaoId") %></td>//由于 variableInstances对象延迟加载,在取得变量的时候出错了 
		<td>${task.name}</td>
    		<td>${task.create}</td>
    		<td><input type="button" taskid="${task.id}" value="同意" onclick="agree(this.taskid);" /><input type="button" taskid="${task.id}" value="不同意" onclick="disagree(this.taskid);" /></td>
    	</tr>
    	</logic:iterate>
    </table>

在取得任务的"baoxiaoId"变量时会出错,提示如下:
failed to lazily initialize a collection of role: org.jbpm.taskmgmt.exe.TaskInstance.variableInstances, no session or session was closed
错误大概意思是
org.jbpm.taskmgmt.exe.TaskInstance.variableInstances session已经关闭,延迟加载失败
在action中不把jbpmcontext对象关闭就没这问题了,但是此对象不关闭肯定是不合理的.
难道把jbpm包中自带的map文件的延迟加载去掉??
各位有什么好的解决办法啊?

问题已经解决:思路是使用过滤器,其中jbpm有个自带的过滤器就可以用,不用自己去写,具体请看jbpm-jpdl-3.2.3\src\jpdl\org\jbpm\web\JbpmContextFilter.java
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics