redis/jedis · error · IllegalStateException
It is not allowed to create Transaction from this
Error message
It is not allowed to create Transaction from this ${getClass()} What it means
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.
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().
Example fix
// before RedisClusterClient c = ...; AbstractTransaction t = c.transaction(true); // throws // after RedisClient c = RedisClient.builder().endpoint(ep).build(); AbstractTransaction t = c.transaction(true);
Defensive patterns
Strategy: type-guard
Validate before calling
AbstractTransaction t = null;
try { t = client.transaction(true); } catch (IllegalStateException e) { /* unsupported */ } Type guard
boolean supportsTx = client instanceof RedisClient || client instanceof UnifiedJedisWithProvider; // structural check
Try / catch
try {
AbstractTransaction t = client.transaction(true);
} catch (IllegalStateException e) {
// use cluster transaction API or standalone client
} Prevention
- Use RedisClient for MULTI/EXEC
- Use cluster transaction API on cluster clients
- Don't return null from createDefaultConnectionProvider() in custom builders
When it happens
Trigger: 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.
Common situations: Porting standalone transactional code to a cluster client; unit tests instantiating UnifiedJedis directly; custom builder clients overriding createDefaultConnectionProvider to return null.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- It is not allowed to create Pipeline from this
- Support only execute to replica in ClusterCommandExecutor
- Command '' with request policy cannot be executed in…
- Support only execute to replica in ClusterCommandExecutor
- Broadcast command is only supported in…
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/77c220008b40168d.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/UnifiedJedis.java:6018
} else {
return new Pipeline(provider.getConnection(), true, commandObjects);
}
}
/**
* @return transaction object
*/
public AbstractTransaction multi() {
return transaction(true);
}
/**
* @param doMulti {@code false} should be set to enable manual WATCH, UNWATCH and MULTI
* @return transaction object
*/
public AbstractTransaction transaction(boolean doMulti) {
if (provider == null) {
throw new IllegalStateException("It is not allowed to create Transaction from this " + getClass());
} else if (provider instanceof MultiDbConnectionProvider) {
return new MultiDbTransaction((MultiDbConnectionProvider) provider, doMulti, commandObjects);
} else {
return new Transaction(provider.getConnection(), doMulti, true, commandObjects);
}
}
/**
* @deprecated Deprecated in Jedis 7.4.0.
* Use {@link #executeCommand(CommandArguments)} with a {@link CommandArguments} object directly.
* <pre>{@code
* jedis.executeCommand(new CommandArguments(PING));
* }</pre>
*/
@Deprecated
public Object sendCommand(ProtocolCommand cmd) {
return executeCommand(commandObjects.commandArguments(cmd));
}View on GitHub (pinned to 6dac31d4c2)