以下是我的一个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部分代码如下
<logic:iterate id="task" scope="request" name="list">//由于 variableInstances对象延迟加载,在取得变量的时候出错了 </logic:iterate> <table> <tbody><tr> <td>报销单ID</td> <td>环节名称</td> <td>建立时间</td> <td>操作</td> </tr> <tr><td><%=((TaskInstance) task).getVariable("baoxiaoId") %></td><td>${task.name}</td><td>${task.create}</td><td><input type="button" value="同意"><input type="button" value="不同意"></td></tr></tbody></table></pre>
在取得任务的"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文件的延迟加载去掉??
各位有什么好的解决办法啊?