{"record":{"id":"746f939a3e29b8cb","repo":"flowable/flowable-engine","slug":"user-s-could-not-be-found","errorCode":null,"errorMessage":"user (%s) could not be found","messagePattern":"user \\((.+?)\\) could not be found","errorType":"exception","errorClass":"UsernameNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-spring-security/src/main/java/org/flowable/spring/security/FlowableUserDetailsService.java","lineNumber":59,"sourceCode":"\n    public FlowableUserDetailsService(IdmIdentityService identityService) {\n        this.identityService = identityService;\n    }\n\n    @Override\n    public UserDetails loadUserByUsername(String userId)\n            throws UsernameNotFoundException {\n        User user = null;\n        try {\n            user = this.identityService.createUserQuery()\n                    .userId(userId)\n                    .singleResult();\n        } catch (FlowableException ex) {\n            // don't care\n        }\n\n        if (null == user) {\n            throw new UsernameNotFoundException(\n                    String.format(\"user (%s) could not be found\", userId));\n        }\n\n        return createFlowableUser(user);\n    }\n\n    protected FlowableUser createFlowableUser(User user) {\n\n        String userId = user.getId();\n        List<Privilege> userPrivileges = identityService.createPrivilegeQuery().userId(userId).list();\n        Set<GrantedAuthority> grantedAuthorities = new HashSet<>();\n        for (Privilege userPrivilege : userPrivileges) {\n            grantedAuthorities.add(new SimpleGrantedAuthority(userPrivilege.getName()));\n        }\n\n        List<Group> groups = identityService.createGroupQuery().groupMember(userId).list();\n        if (!groups.isEmpty()) {\n            List<String> groupIds = new ArrayList<>(groups.size());","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-spring-security/src/main/java/org/flowable/spring/security/FlowableUserDetailsService.java#L41-L77","documentation":"Flowable's Spring Security integration implements UserDetailsService on top of the Flowable identity (IDM) tables. loadUserByUsername looks up the user via the IdmIdentityService; if no row matches the given userId (after swallowing the FlowableException from the query), it throws Spring Security's UsernameNotFoundException. It signals that authentication cannot proceed because the account does not exist in the Flowable IDM database.","triggerScenarios":"Calling FlowableUserDetailsService.loadUserByUsername(userId) when the ACT_ID_USER table has no row with that ID; also triggered indirectly by any Spring Security authentication (form login, DaoAuthenticationProvider) configured with this UserDetailsService for a username that is not a Flowable IDM user.","commonSituations":"Users provisioned in an external directory (LDAP/AD) but the Flowable IDM tables were never synced; typos or case-sensitivity mismatches in usernames; pointing the app at a fresh database without running the identity data scripts; deleting a user while active sessions still reference them.","solutions":["Insert the user into the IDM schema (ACT_ID_USER) via the IdmIdentityService (idmIdentityService.createUser(...).setPassword(...)) or the Flowable Admin/IDM UI, then retry login.","If users live in LDAP/AD, configure Flowable's LDAP identity integration or a different UserDetailsService instead of relying on the IDM tables.","Verify the application is connected to the intended database (check flowable/database config) — the user may exist in another environment's DB.","Catch UsernameNotFoundException in your authentication handling and show a clear 'unknown user' message instead of a generic failure."],"exampleFix":"// before (user missing at login)\nauthenticationManager.authenticate(new UsernamePasswordAuthenticationToken(\"jsmith\", \"secret\"));\n// throws UsernameNotFoundException: user (jsmith) could not be found\n\n// after: provision the user first if missing\nif (idmIdentityService.createUserQuery().userId(\"jsmith\").singleResult() == null) {\n    User u = idmIdentityService.newUser(\"jsmith\");\n    u.setPassword(passwordEncoder.encode(\"secret\"));\n    u.setFirstName(\"John\");\n    u.setLastName(\"Smith\");\n    idmIdentityService.saveUser(u);\n}\nauthenticationManager.authenticate(new UsernamePasswordAuthenticationToken(\"jsmith\", \"secret\"));","handlingStrategy":"try-catch","validationCode":"boolean exists = idmIdentityService.createUserQuery().userId(userId).singleResult() != null;","typeGuard":null,"tryCatchPattern":"try {\n    UserDetails user = userDetailsService.loadUserByUsername(userId);\n} catch (UsernameNotFoundException e) {\n    // provision or reject with 'unknown user' response; never reveal stack trace to clients\n}","preventionTips":["Provision users into ACT_ID_USER (or sync from LDAP) as part of environment setup","Verify DB connection points at the environment you expect before debugging auth failures","Normalize username case/trimming before lookup"],"tags":["spring-security","identity","user-not-found","authentication"],"backgroundTag":"user-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}