Jbpm 3.2.6 Class cast Exception Once this Exception comes flow breaks
ameen5271 Feb 7, 2017 7:32 AMsometimes I am getting following exception on submitting task, this exception occurs rarely and it is happening only in production environment not able to reproduce in local.
java.lang.ClassCastException: org.jbpm.graph.def.Node cannot be cast to org.jbpm.graph.node.TaskNode at org.jbpm.graph.node.TaskNode$$FastClassByCGLIB$$923668a4.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161) at org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$53e0141a.completionTriggersSignal(<generated>) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:432) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:391) at com.liferay.jbpm.WorkflowServiceUtil.completeTask(MonorailWorkflowServiceUtil.java:308) at com.liferay.jbpm.WorkflowServiceUtil.process(MonorailWorkflowServiceUtil.java:72) at com.liferay.jbpm.servlet.JBPMServlet.service(JBPMServlet.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)
Fallowing is my code
private String completeTask(long processInstanceId, String taskName, String transition, long userId, long orgId, Map<String, Object> processVariables, long taskInstanceId, String driver, String url, String userName, String password) { JbpmContext jbpmContext = null; String status = "SUCCESS"; long taskId = 0; Connection con = null; try { con = DBConnection.getDBConnetion(driver, url, userName, password); JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance(); jbpmContext = jbpmConfiguration.createJbpmContext(); con.setAutoCommit(false); jbpmContext.setConnection(con); ProcessInstance processInstance = jbpmContext.getProcessInstance(processInstanceId); TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance(); Collection<TaskInstance> taskInstances = taskMgmtInstance.getTaskInstances(); for (TaskInstance taskInstance : taskInstances) { String strTaskName = taskInstance.getTask().getName(); taskId = taskInstance.getId(); // log.info("Complete Task - TaskName:" + strTaskName + // ", Task to complete: " + // taskName); if (taskInstanceId > 0 && taskInstanceId == taskId) { log.info("Complete Task - Task to complete:" + strTaskName); if (null != processVariables && processVariables.size() > 0) { try { processVariables.remove(""); processVariables.remove(null); } catch (Exception e) { e.printStackTrace(); } taskInstance.addVariables(processVariables); } log.info("Complete Task - transition:" + transition); if (null != transition && transition.length() > 0) { taskInstance.end(transition); } else { taskInstance.end(); } jbpmContext.save(taskInstance); break; } } con.commit(); } catch (Exception e) { try { con.rollback(); } catch (SQLException e1) { e.printStackTrace(); } status = "FAILED"; e.printStackTrace(); } finally { jbpmContext.close(); DBConnection.closeConnection(con); } }