testcontainers/testcontainers-java · error · IllegalStateException

Alternator is not enabled

Error message

Alternator is not enabled

What it means

ScyllaDBContainer.getAlternatorEndpoint returns the HTTP endpoint of ScyllaDB's Alternator (DynamoDB-compatible) API, but only if Alternator mode was enabled on the container. If the container was started without enabling Alternator, the endpoint does not exist and the method throws IllegalStateException.

Solutions

  1. Enable Alternator before starting: call container.withAlternatorEnabled() (or the constructor/config option) prior to container.start().
  2. Guard calls with an isEnabled/flag check or only call getAlternatorEndpoint in tests that configure Alternator.
  3. If Alternator is not needed, use the CQL API (getContactPoint/getShardAwareContactPoint) instead.
  4. Verify the image supports Alternator and that no create-cmd modifiers strip the alternator flag.

Example fix

// before
ScyllaDBContainer container = new ScyllaDBContainer("scylladb/scylla");
container.start();
String endpoint = container.getAlternatorEndpoint(); // throws
// after
ScyllaDBContainer container = new ScyllaDBContainer("scylladb/scylla")
    .withAlternatorEnabled();
container.start();
String endpoint = container.getAlternatorEndpoint();
Defensive patterns

Strategy: validation

Validate before calling

if (!alternatorEnabled) {
  throw new IllegalStateException("Call withAlternatorEnabled() before start() to use getAlternatorEndpoint()");
}
InetSocketAddress alternator = container.getAlternatorEndpoint();

Try / catch

try {
  String endpoint = container.getAlternatorEndpoint();
} catch (IllegalStateException e) {
  if (e.getMessage().contains("Alternator is not enabled")) {
    throw new IllegalStateException("Enable Alternator with withAlternatorEnabled() before start()"); }
  throw e;
}

Prevention

When it happens

Trigger: Calling container.getAlternatorEndpoint() on a ScyllaDBContainer created without withAlternatorEnabled() (or equivalent config) before/without starting it in Alternator mode.

Common situations: Tests that copy ScyllaDB examples using the Alternator API but forget the enable call; enabling Alternator only in some test profiles; using a shared container config where Alternator was removed.

Related errors


AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12). Data as JSON: /api/errors/4b1840da24e51688. Report an issue: GitHub.

Appendix: source

Thrown at modules/scylladb/src/main/java/org/testcontainers/scylladb/ScyllaDBContainer.java:105

        return this;
    }

    /**
     * Retrieve an {@link InetSocketAddress} for connecting to the ScyllaDB container via the driver.
     *
     * @return A InetSocketAddress representation of this ScyllaDB container's host and port.
     */
    public InetSocketAddress getContactPoint() {
        return new InetSocketAddress(getHost(), getMappedPort(CQL_PORT));
    }

    public InetSocketAddress getShardAwareContactPoint() {
        return new InetSocketAddress(getHost(), getMappedPort(SHARD_AWARE_PORT));
    }

    public String getAlternatorEndpoint() {
        if (!this.alternatorEnabled) {
            throw new IllegalStateException("Alternator is not enabled");
        }
        return "http://" + getHost() + ":" + getMappedPort(ALTERNATOR_PORT);
    }
}

View on GitHub (pinned to 8e549514e3)