code: protected TaskInstance createTaskInstance() throws ActivityException {
          try {
              String taskTemplate = getAttributeValue(ATTRIBUTE_TASK_TEMPLATE);
              if (taskTemplate == null)
                  throw new ActivityException("Missing attribute: " + ATTRIBUTE_TASK_TEMPLATE);
              String templateVersion = getAttributeValue(ATTRIBUTE_TASK_TEMPLATE_VERSION);
              AssetVersionSpec spec = new AssetVersionSpec(taskTemplate, templateVersion == null ? "0" : templateVersion);
              TaskTemplate template = TaskTemplateCache.getTaskTemplate(spec);
              if (template == null)
                  throw new ActivityException("Task template not found: " + spec);
  
              String taskName = template.getTaskName();
              String title = null;
              if (ActivityRuntimeContext.isExpression(taskName)) {
                  title = getRuntimeContext().evaluateToString(taskName);
              }
  
              String comments = null;
              Exception exception = (Exception) getVariableValue("exception");
              if (exception != null) {
                  comments = exception.toString();
                  if (exception instanceof ActivityException) {
                      ActivityRuntimeContext rc = ((ActivityException)exception).getRuntimeContext();
                      if (rc != null && rc.getProcess() != null) {
                          comments = rc.getProcess().getFullLabel() + "\n" + comments;
                      }
                  }
              }
  
              return createTaskInstance(spec, getMasterRequestId(), getProcessInstanceId(),
                              getActivityInstanceId(), getWorkTransitionInstanceId(), title, comments);
          }
          catch (Exception ex) {
              throw new ActivityException(ex.getMessage(), ex);
          }
      }
docs: Creates a new task instance based on the configured template for this activity.