{"record":{"id":"77c220008b40168d","repo":"redis/jedis","slug":"it-is-not-allowed-to-create-transaction-from-this-77c220","errorCode":null,"errorMessage":"It is not allowed to create Transaction from this ${getClass()}","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/UnifiedJedis.java","lineNumber":6018,"sourceCode":"    } else {\n      return new Pipeline(provider.getConnection(), true, commandObjects);\n    }\n  }\n\n  /**\n   * @return transaction object\n   */\n  public AbstractTransaction multi() {\n    return transaction(true);\n  }\n\n  /**\n   * @param doMulti {@code false} should be set to enable manual WATCH, UNWATCH and MULTI\n   * @return transaction object\n   */\n  public AbstractTransaction transaction(boolean doMulti) {\n    if (provider == null) {\n      throw new IllegalStateException(\"It is not allowed to create Transaction from this \" + getClass());\n    } else if (provider instanceof MultiDbConnectionProvider) {\n      return new MultiDbTransaction((MultiDbConnectionProvider) provider, doMulti, commandObjects);\n    } else {\n      return new Transaction(provider.getConnection(), doMulti, true, commandObjects);\n    }\n  }\n\n  /**\n   * @deprecated Deprecated in Jedis 7.4.0.\n   * Use {@link #executeCommand(CommandArguments)} with a {@link CommandArguments} object directly.\n   * <pre>{@code\n   * jedis.executeCommand(new CommandArguments(PING));\n   * }</pre>\n   */\n  @Deprecated\n  public Object sendCommand(ProtocolCommand cmd) {\n    return executeCommand(commandObjects.commandArguments(cmd));\n  }","sourceCodeStart":6000,"sourceCodeEnd":6036,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/UnifiedJedis.java#L6000-L6036","documentation":"UnifiedJedis.transaction(doMulti) requires a ConnectionProvider to create a Transaction bound to a connection. When provider is null (client type that doesn't support transactions) Jedis throws IllegalStateException naming the concrete class.","triggerScenarios":"Calling transaction(true)/transaction(false) on a UnifiedJedis subclass whose provider is null — e.g. certain cluster/failover clients or custom clients built without a ConnectionProvider.","commonSituations":"Porting standalone transactional code to a cluster client; unit tests instantiating UnifiedJedis directly; custom builder clients overriding createDefaultConnectionProvider to return null.","solutions":["Use RedisClient (standalone) which supports transactions via Transaction.","For cluster transactions, use the cluster-specific transaction API (JedisClusterTransaction/ClusterTransaction).","Ensure your custom builder installs a ConnectionProvider in createDefaultConnectionProvider().","Verify the client class supports MULTI/EXEC before calling transaction()."],"exampleFix":"// before\nRedisClusterClient c = ...;\nAbstractTransaction t = c.transaction(true); // throws\n// after\nRedisClient c = RedisClient.builder().endpoint(ep).build();\nAbstractTransaction t = c.transaction(true);","handlingStrategy":"type-guard","validationCode":"AbstractTransaction t = null;\ntry { t = client.transaction(true); } catch (IllegalStateException e) { /* unsupported */ }","typeGuard":"boolean supportsTx = client instanceof RedisClient || client instanceof UnifiedJedisWithProvider; // structural check","tryCatchPattern":"try {\n  AbstractTransaction t = client.transaction(true);\n} catch (IllegalStateException e) {\n  // use cluster transaction API or standalone client\n}","preventionTips":["Use RedisClient for MULTI/EXEC","Use cluster transaction API on cluster clients","Don't return null from createDefaultConnectionProvider() in custom builders"],"tags":["transaction","unsupported-operation","jedis","cluster"],"backgroundTag":"unsupported-operation","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"}