I have to following code: | protected TaskInstance locateTask(ContextInstance ctx, JbpmContext jbpmContext) throws ApplicationException { | String searchValue = (String) ctx.getVariable(contextKey); | if (searchValue == null || searchValue.trim().equals("")) | return null; | String query = String.format("select t.ID_ TASK_ID from JBPM_TASKINSTANCE t , JBPM_VARIABLEINSTANCE vi " | + "where vi.STRINGVALUE_ = '%s' and vi.TOKEN_ = t.TOKEN_ and (t.ISOPEN_ = 1 or t.ISSUSPENDED_ = 1)" | + " and t.END_ is null and t.NAME_ ", new Object[] {searchValue}); | | String inString; | if (!notInTaskType) { | inString = String.format("in ( %s )", new Object[] {taskName}); | } | else { | // we're looking for tasks which are not of types given | inString = String.format("not in ( %s )", new Object[] {taskName}); | } | | query += inString; | | SQLQuery sqlQuery = jbpmContext.getSession().createSQLQuery(query).addScalar("TASK_ID", Hibernate.LONG); | List result = sqlQuery.list(); | // Collection<DbaseFieldList> result = JDBCHelper.getInstance().runSelectStatement(query, | // (Connection) ctx.getTransientVariable(FlowVariables.CONNECTION)); | if (result == null || result.isEmpty()) { | return null; | } | // always take the first one found! usually there should be only one task in existence | // long taskId = Long.parseLong(result.iterator().next().get("ID_").getValueAsString()); | Long taskId = (Long) result.get(0); | if (logger.isLoggable(Level.FINEST)) | logger.finest("Found a Task with ID: " + taskId); | TaskInstance task; | try { | task = TaskManager.loadInstance(taskId, jbpmContext); | if (logger.isLoggable(Level.FINEST)) | logger.finest(task.toString()); | } | catch (ApplicationException ae) { | // the task is either being opened by a user of is being finished by a user. | Long userId = (Long) ctx.getTransientVariable(FlowVariables.USER_ID); | if (userId != null) { | String folderId = (String) ctx.getVariable(FlowVariables.FOLDER_ID); | String text = ServerSideResources.translate("Msg38") + " " + folderId; | Set<String> users = new HashSet<String>(); | users.add(userId.toString()); | MessageManager.getInstance().sendMessageToUsers(users, text); | } | return null; | } | return task; | } | | public static EmiTaskInstance loadInstance(long taskId, JbpmContext ctx) throws ApplicationException { | EmiTaskMgmntSession mgmtSession = (EmiTaskMgmntSession) ctx.getTaskMgmtSession(); | try { | return (EmiTaskInstance) mgmtSession.loadTaskInstance(taskId); | } | catch (JbpmException e) { | throw new ApplicationException("ALREADY_ASSIGNED", e.getMessage()); | } | } | |
In one process I call a subprocess. Before the subprocess is called I run an action which closes a Task (Hence Task A). At the beginning of the subprocess I run an action which runs the locateTask from above to locate open tasks that have a certain value. The select I run using the open hibernate session returns finding Task A although Task A is closed i.e has an end date, and is not marked as open or suspended. More over, on the next couple of lines of code I load the task with the id the select returned and try to resume it, this fails on exception that says I can't resume a task that has been closed. How can the select find this task if it closed? I'm running a Jbpm 3.2 in a clustered environment, which means I'm using an XA DataSource and XA transactions. A Transaction is opened before I begin and the commit is only after The subprocess has reached a blocking state. The only thing I can think of is that for some reason the connection used for the query is not the connection used for loading and closing the task. I also want to mention that the same exact code does not fail in a non clusterd environment. I'll be happy to read any thoughts on this matter that can point me to a direction.... View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4196209#4196209 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4196209 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user