When I call formService.getRenderedTaskForm with a task id of a task that just happens to be an ad-hoc task a Null Pointer Exception is thrown in Activiti 5.9. I'm assuming this is a bug but am posting here first. My code: public DataHandler getForm() {
DataHandler dh = null;
FormService formService = processEngine.getFormService();
String form = null;
if ((form = (String)formService.getRenderedTaskForm(task.getId())) != null) {
}
Stacktrace as follows:2012-05-02 22:34:44,626 SEVERE [org.activiti.engine.impl.interceptor.CommandContext] (http-localhost%2F127.0.0.1-8080-8) Error while closing command context: java.lang.NullPointerException
at org.activiti.engine.impl.cmd.GetRenderedTaskFormCmd.execute(GetRenderedTaskFormCmd.java:51) [:5.9]
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) [:5.9]
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42) [:5.9]
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) [:5.9]
at org.activiti.engine.impl.FormServiceImpl.getRenderedTaskForm(FormServiceImpl.java:44) [:5.9]
at com.ajita.ical.activiti.actTask.getForm(actTask.java:187) [:]
Looking at the source of GetRenderedTaskFormCmd it seems that a returned null task definition from getTaskDefinition in org.activiti.engine.impl.persistence.entity.TaskEntity is the likely cause.}
TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
if (taskFormHandler == null) {
return null;
}Presumably ad-hoc tasks have no task definition? I've confirmed this by the db record for the task in question.My workaround is to check if (task.getTaskDefinitionKey() !=null) {first, but I would still expect this to be handled gracefully.