NullPointerException executing timer
danikenan Oct 13, 2005 11:36 PMWe have a rather simple mechanism to execute timers.
Following is the relevant code:
private static final String EQL_FIND_TIMER_BY_ID = "select ti " + "from org.jbpm.scheduler.exe.Timer as ti " + "where ti.id = :timerId"; @SuppressWarnings("unchecked") public void executeTimer(final long timerId) { JbpmSession jbpmSession = getJbpmSessionFactory().openJbpmSessionAndBeginTransaction(); Session hibernateSession = jbpmSession.getSession(); SchedulerSession schedulerSession = jbpmSession.getSchedulerSession(); try { Query query = hibernateSession.createQuery(EQL_FIND_TIMER_BY_ID); Timer timer = (Timer) query.setLong("timerId", timerId).uniqueResult(); if (timer.isDue()) { timer.execute(); } } catch (Exception e) { LOG.error("Error executin timer id " + timerId, e); } finally { jbpmSession.close(); } }
any call to executeTimer with an id of a due timer would generate the following error:
java.lang.NullPointerException at org.jbpm.graph.def.GraphElement.getRuntimeActionsForEvent(GraphElement.java:208) at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:153) at org.jbpm.scheduler.exe.Timer.execute(Timer.java:54) at com.cbittech.peglogic.core.engine.JbpmWrapperBean.executeTimer(JbpmWrapperBean.java:256) at com.cbittech.peglogic.core.engine.JbpmWrapperTest.testExecuteTimers(JbpmWrapperTest.java:88) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
This is due to the fact that in GraphElement.getRuntimeActionsForEvent the executionContext has a null processInstance.
What is wrong?