redis/jedis · error · IllegalStateException

It is not allowed to create Transaction from this

Error message

It is not allowed to create Transaction from this 

What it means

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.

Solutions

  1. Build the client via RedisMultiDbClient/AbstractClientBuilder so the provider is initialized before use
  2. Check that build() succeeded and the client is fully constructed before calling transaction()
  3. Use the correct client type that supports MultiDbTransaction

Example fix

// before
MultiDbClient client = new MultiDbClient(); // provider not initialized
client.transaction(true); // IllegalStateException
// after
MultiDbClient client = RedisMultiDbClient.builder()
    .config(multiDbConfig)
    .build();
MultiDbTransaction tx = client.transaction(true);
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the client was built through its builder so the provider exists
if (client == null || !client.isReady()) {
  throw new IllegalStateException("Client not initialized; cannot open transaction");
}

Prevention

When it happens

Trigger: 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.

Common situations: Tests constructing MultiDbClient through non-standard constructors; using the client after an init failure; confusing MultiDbClient with a subclass that does not support transactions.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/b9628c07d348f9e3. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/MultiDbClient.java:291

   * <p>
   * The returned transaction supports the same resilience features as the main client, including
   * automatic failover during transaction execution.
   * </p>
   * @return a new MultiDbTransaction instance
   */
  @Override
  public MultiDbTransaction multi() {
    return new MultiDbTransaction((MultiDbConnectionProvider) provider, true, commandObjects);
  }

  /**
   * @param doMulti {@code false} should be set to enable manual WATCH, UNWATCH and MULTI
   * @return transaction object
   */
  @Override
  public MultiDbTransaction transaction(boolean doMulti) {
    if (provider == null) {
      throw new IllegalStateException(
          "It is not allowed to create Transaction from this " + getClass());
    }

    return new MultiDbTransaction(getMultiDbConnectionProvider(), doMulti, commandObjects);
  }

  /**
   * Returns the currently active database endpoint.
   * <p>
   * The active endpoint is the one currently being used for all operations. It can change at any
   * time due to health checks, failover, failback, or manual switching.
   * </p>
   * @return the active database endpoint
   */
  public Endpoint getActiveDatabaseEndpoint() {
    return getMultiDbConnectionProvider().getDatabase().getEndpoint();
  }

View on GitHub (pinned to 6dac31d4c2)