{"record":{"id":"749975f3d7efc9d9","repo":"flowable/flowable-engine","slug":"entityclass-is-null-749975","errorCode":null,"errorMessage":"entityClass is null","messagePattern":"entityClass is null","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTableNameCmd.java","lineNumber":43,"sourceCode":"\r\n    private static final long serialVersionUID = 1L;\r\n\r\n    protected Class<?> entityClass;\r\n    protected boolean withPrefix = true;\r\n\r\n    public GetTableNameCmd(Class<?> entityClass) {\r\n        this.entityClass = entityClass;\r\n    }\r\n\r\n    public GetTableNameCmd(Class<?> entityClass, boolean withPrefix) {\r\n        this.entityClass = entityClass;\r\n        this.withPrefix = withPrefix;\r\n    }\r\n\r\n    @Override\r\n    public String execute(CommandContext commandContext) {\r\n        if (entityClass == null) {\r\n            throw new FlowableIllegalArgumentException(\"entityClass is null\");\r\n        }\r\n\r\n        String databaseTablePrefix = getDbSqlSession(commandContext).getDbSqlSessionFactory().getDatabaseTablePrefix();\r\n        String tableName = EntityToTableMap.getTableName(entityClass);\r\n\r\n        if (withPrefix) {\r\n            return databaseTablePrefix + tableName;\r\n        } else {\r\n            return tableName;\r\n        }\r\n    }\r\n\r\n}\r\n","sourceCodeStart":25,"sourceCodeEnd":57,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTableNameCmd.java#L25-L57","documentation":"GetTableNameCmd resolves the database table name for an entity class via EntityToTableMap. The command requires a non-null entity Class to look up the mapping, so it validates at the start of execute() and throws FlowableIllegalArgumentException if none was supplied.","triggerScenarios":"Calling managementService.getTableName(EntityClass, withPrefix) (or executing GetTableNameCmd directly) with a null Class argument, e.g. passing a variable that was expected to hold an entity class but is null.","commonSituations":"Reflectively resolving an entity class by name where the class name is wrong or the class failed to load; generic helper code that forwards an entity class parameter which is null on some code paths.","solutions":["Ensure a concrete Flowable entity class (e.g. TaskEntity.class, ExecutionEntityImpl.class) is passed to getTableName; never pass a null Class","If the class is resolved dynamically, verify the Class lookup (Class.forName / loader) succeeded before calling the command","Check that the variable holding the entity type is initialized on all branches before invoking the command"],"exampleFix":"// before\nString table = managementService.getTableName(entityClass, true); // entityClass is null\n// after\nif (entityClass == null) {\n    throw new IllegalStateException(\"entity class must be resolved before getTableName\");\n}\nString table = managementService.getTableName(entityClass, true);","handlingStrategy":"validation","validationCode":"if (entityClass == null) {\n    throw new IllegalArgumentException(\"entityClass must be provided\");\n}","typeGuard":"boolean hasEntityClass(Object c) {\n    return c instanceof Class<?> && Entity.class.isAssignableFrom((Class<?>) c);\n}","tryCatchPattern":"try {\n    String table = managementService.getTableName(entityClass, true);\n} catch (FlowableIllegalArgumentException e) {\n    // entityClass was null; fix caller\n    throw new IllegalStateException(\"entityClass required for table lookup\", e);\n}","preventionTips":["Always pass a concrete entity class literal, not a nullable variable","Validate dynamic class resolution before invoking the command"],"tags":["java","flowable","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-14T05:17:10.506Z"}