{"record":{"id":"b9628c07d348f9e3","repo":"redis/jedis","slug":"it-is-not-allowed-to-create-transaction-from-this","errorCode":null,"errorMessage":"It is not allowed to create Transaction from this ","messagePattern":"It is not allowed to create Transaction from this ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/MultiDbClient.java","lineNumber":291,"sourceCode":"   * <p>\n   * The returned transaction supports the same resilience features as the main client, including\n   * automatic failover during transaction execution.\n   * </p>\n   * @return a new MultiDbTransaction instance\n   */\n  @Override\n  public MultiDbTransaction multi() {\n    return new MultiDbTransaction((MultiDbConnectionProvider) provider, true, commandObjects);\n  }\n\n  /**\n   * @param doMulti {@code false} should be set to enable manual WATCH, UNWATCH and MULTI\n   * @return transaction object\n   */\n  @Override\n  public MultiDbTransaction transaction(boolean doMulti) {\n    if (provider == null) {\n      throw new IllegalStateException(\n          \"It is not allowed to create Transaction from this \" + getClass());\n    }\n\n    return new MultiDbTransaction(getMultiDbConnectionProvider(), doMulti, commandObjects);\n  }\n\n  /**\n   * Returns the currently active database endpoint.\n   * <p>\n   * The active endpoint is the one currently being used for all operations. It can change at any\n   * time due to health checks, failover, failback, or manual switching.\n   * </p>\n   * @return the active database endpoint\n   */\n  public Endpoint getActiveDatabaseEndpoint() {\n    return getMultiDbConnectionProvider().getDatabase().getEndpoint();\n  }\n","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/MultiDbClient.java#L273-L309","documentation":"MultiDbClient.transaction() requires the underlying connection provider to be initialized. When the provider field is null (the client was not built with a MultiDbConnectionProvider), it throws IllegalStateException indicating transactions cannot be created from this class.","triggerScenarios":"Calling transaction()/transaction(doMulti) on a MultiDbClient instance whose provider was never set — e.g. a partially built client, a client obtained through a path that skipped provider initialization, or use before build() completed.","commonSituations":"Tests constructing MultiDbClient through non-standard constructors; using the client after an init failure; confusing MultiDbClient with a subclass that does not support transactions.","solutions":["Build the client via RedisMultiDbClient/AbstractClientBuilder so the provider is initialized before use","Check that build() succeeded and the client is fully constructed before calling transaction()","Use the correct client type that supports MultiDbTransaction"],"exampleFix":"// before\nMultiDbClient client = new MultiDbClient(); // provider not initialized\nclient.transaction(true); // IllegalStateException\n// after\nMultiDbClient client = RedisMultiDbClient.builder()\n    .config(multiDbConfig)\n    .build();\nMultiDbTransaction tx = client.transaction(true);","handlingStrategy":"validation","validationCode":"// Ensure the client was built through its builder so the provider exists\nif (client == null || !client.isReady()) {\n  throw new IllegalStateException(\"Client not initialized; cannot open transaction\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always construct MultiDbClient via RedisMultiDbClient.builder().build()","Do not invoke transaction() on partially constructed or failed-build clients","Verify init logs/exceptions before using the client in application code"],"tags":["redis","multi-db","transaction","uninitialized-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}