BusinessCalendarImpl throws null pointer exception
joshsiaw Nov 18, 2009 5:24 AM=== Environment ==============================
- jBPM Version : 4.2
- Database : MySql 5.0.67
- JDK : 1.6.0_16
- Container : 1.6.0_16
- Configuration : default jbpm.cfg.xml copied from Examples project
- Libraries : default jBPM 4.2 libraries
=== Process ==================================
<?xml version="1.0" encoding="UTF-8"?> <process name="test" xmlns="http://jbpm.org/4.0/jpdl"> <start g="193,63,48,48" name="start1"> <transition to="Inspection"/> </start> <task assignee="valTech1" g="170,141,92,52" name="Inspection" duedate="10 business hours"> <transition to="Verify Inspection Report" name="timeout" g="11,-7"> </transition> </task> <task assignee="svt" g="147,224,136,52" name="Verify Inspection Report"> <transition to="Valuation"/> </task> <task assignee="avo" g="171,316,92,52" name="Valuation"> <transition to="Certify Valuation"/> </task> <task assignee="vo" g="165,397,106,52" name="Certify Valuation"> <transition to="Billing"/> </task> <task assignee="clerk" g="173,478,92,52" name="Billing"> <transition to="end1"/> </task> <end g="194,558,48,48" name="end1"/> </process>
=== API ===================================
Task task = jbpmServices.getTaskService().createTaskQuery().processDefinitionId("test-1").activityName("Inspection").uniqueResult(); Calendar cal = Calendar.getInstance(); BusinessCalendarImpl businessCalendar = new BusinessCalendarImpl(); Duration duration = new Duration("10 business days"); Date date = businessCalendar.add(cal.getTime(), duration); task.setDuedate(date);
=== Stacktrace ==============================
Exception in thread "main" java.lang.NullPointerException
at org.jbpm.pvm.internal.cal.BusinessCalendarImpl.findDay(BusinessCalendarImpl.java:154)
at org.jbpm.pvm.internal.cal.BusinessCalendarImpl.findDayPart(BusinessCalendarImpl.java:160)
at org.jbpm.pvm.internal.cal.BusinessCalendarImpl.add(BusinessCalendarImpl.java:78)
at eval.tester.tester.testTaskDueDate(tester.java:56)
at eval.tester.tester.main(tester.java:39)
=== Debug logs ==============================
Fails at this point:
protected Day findDay(Date date) { Calendar calendar = createCalendar(); calendar.setTime(date); int weekDayIndex = calendar.get(Calendar.DAY_OF_WEEK); return days[weekDayIndex]; }
=== Problem description =========================
BusinessCalendarImpl throws null pointer exception. Looking through the code it looks like its caused by the days[] being null. Am I using it correctly? Any help would be appreciated.