Buggy code:
@ Service ( "documentService" ) public class DocumentService { private static final Logger log = LoggerFactory . getLogger ( DocumentService . class ) ; protected IdentityService identityService ; protected RuntimeService runtimeService ; protected TaskService taskService ; protected UserService userService ; protected DocumentDao docDao ; @ Autowired public void setDocDao ( DocumentDao docDao ) { } @ Autowired public void setUserService ( UserService userService ) { } @ Autowired public void setTaskService ( TaskService taskService ) { } @ Autowired public void setRuntimeService ( RuntimeService runtimeService ) { } @ Autowired public void setIdentityService ( IdentityService identityService ) { } @ Transactional ( readOnly = true ) public List < Document > getGroupDocumentsByUser ( String userId ) { } @ Transactional public String createDocument ( Document document ) { } public void submitForApproval ( String docId ) { Document doc = this . docDao . read ( docId ) ; DocumentService . log . debug ( "beginning<seq2seq4repair_space>(or<seq2seq4repair_space>continuing)<seq2seq4repair_space>doc<seq2seq4repair_space>approval<seq2seq4repair_space>workflow<seq2seq4repair_space>for<seq2seq4repair_space>doc<seq2seq4repair_space>{}.<seq2seq4repair_space>" , doc . getId ( ) ) ; UserDetails userDetails = this . userService . currentUser ( ) ; if ( ! ( StringUtils . equals ( userDetails . getUsername ( ) , doc . getAuthor ( ) ) ) ) { throw new InvalidAccessException ( "Only<seq2seq4repair_space>the<seq2seq4repair_space>author<seq2seq4repair_space>of<seq2seq4repair_space>a<seq2seq4repair_space>doc<seq2seq4repair_space>can<seq2seq4repair_space>submit<seq2seq4repair_space>for<seq2seq4repair_space>approval" ) ; } doc . setState ( STATE_WAITING_FOR_APPROVAL ) ; Map < String , Object > processVariables = Maps . newHashMap ( ) ; processVariables . put ( "initiator" , doc . getAuthor ( ) ) ; processVariables . put ( "docId" , doc . getId ( ) ) ; processVariables . put ( "docTitle" , doc . getTitle ( ) ) ; processVariables . put ( "docAuthor" , doc . getAuthor ( ) ) ; try { identityService . setAuthenticatedUserId ( userDetails . getUsername ( ) ) ; ProcessInstance current = this . getCurrentProcess ( docId ) ; if ( current == null ) { <START_BUG> String key = Workflow . PROCESS_ID_DOC_APPROVAL ; <END_BUG> current = runtimeService . startProcessInstanceByKey ( key , doc . getId ( ) ) ; } Task task = taskService . createTaskQuery ( ) . processInstanceId ( current . getProcessInstanceId ( ) ) . singleResult ( ) ; taskService . setAssignee ( task . getId ( ) , userDetails . getUsername ( ) ) ; this . docDao . update ( doc ) ; taskService . setVariableLocal ( task . getId ( ) , "taskOutcome" , "Submitted<seq2seq4repair_space>for<seq2seq4repair_space>Approval" ) ; taskService . setVariables ( task . getId ( ) , processVariables ) ; taskService . complete ( task . getId ( ) ) ; } finally { identityService . setAuthenticatedUserId ( null ) ; } } private ProcessInstance getCurrentProcess ( String docId ) { } @ Transactional public void updateDocument ( Document document ) { } @ Transactional ( readOnly = true ) public Document getDocument ( String id ) { } }

Fix:
String key = String . format ( "%s-%s" , PROCESS_ID_DOC_APPROVAL , doc . getGroupId ( ) ) ;