{"record":{"id":"48ecc5a724e8a560","repo":"flowable/flowable-engine","slug":"entityclass-is-null-48ecc5","errorCode":null,"errorMessage":"entityClass is null","messagePattern":"entityClass is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/GetTableNameCmd.java","lineNumber":37,"sourceCode":"import org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.idm.engine.impl.db.EntityToTableMap;\n\npublic class GetTableNameCmd implements Command<String>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    private Class<?> entityClass;\n\n    public GetTableNameCmd(Class<?> entityClass) {\n        this.entityClass = entityClass;\n    }\n\n    @Override\n    public String execute(CommandContext commandContext) {\n        if (entityClass == null) {\n            throw new FlowableIllegalArgumentException(\"entityClass is null\");\n        }\n\n        String databaseTablePrefix = getDbSqlSession(commandContext).getDbSqlSessionFactory().getDatabaseTablePrefix();\n        String tableName = EntityToTableMap.getTableName(entityClass);\n\n        return databaseTablePrefix + tableName;\n    }\n\n}\n","sourceCodeStart":19,"sourceCodeEnd":47,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/GetTableNameCmd.java#L19-L47","documentation":"GetTableNameCmd resolves the database table name for a Flowable entity class. The command validates its entityClass constructor argument before doing any work; since the table lookup (EntityToTableMap.getTableName) requires a concrete entity type, a null class cannot resolve to a table, so a FlowableIllegalArgumentException is thrown immediately.","triggerScenarios":"Calling managementService executeCommand(new GetTableNameCmd(null)) or invoking an API wrapper (e.g. table-name query helpers) while passing a null Class<?> argument for the entity.","commonSituations":"Building dynamic queries where the entity class is resolved via reflection or configuration and the resolution silently returns null (typo'd class name, missing module dependency, uninitialized field).","solutions":["Pass a concrete Flowable entity class, e.g. new GetTableNameCmd(org.flowable.idm.api.User.class)","Check where the Class value comes from; fix the reflection/config lookup that produced null","Wrap the call in try-catch FlowableIllegalArgumentException only if null is an expected input to handle gracefully"],"exampleFix":"// before\nString table = managementService.executeCommand(new GetTableNameCmd(entityClass));\n// after\nif (entityClass == null) {\n    entityClass = org.flowable.idm.api.User.class; // or fail fast with a clear message\n}\nString table = managementService.executeCommand(new GetTableNameCmd(entityClass));","handlingStrategy":"validation","validationCode":"if (entityClass == null) throw new IllegalArgumentException(\"entityClass must be a non-null Flowable entity Class\");","typeGuard":"boolean isValidEntity(Class<?> c) { return c != null && (org.flowable.idm.api.User.class.isAssignableFrom(c) || c == org.flowable.idm.api.Group.class); }","tryCatchPattern":"try { String table = cmd.execute(ctx); } catch (FlowableIllegalArgumentException e) { log.error(\"No entity class supplied\", e); }","preventionTips":["Never build commands from values resolved by reflection without a null check","Centralize entity-class constants instead of config-driven lookups","Fail fast at config load time when entity classes are unreadable"],"tags":["flowable","idm","null-argument","validation"],"backgroundTag":"null-argument","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"}