testcontainers/testcontainers-java · error · IllegalStateException

Unable to create solr core: Stdout

Error message

Unable to create solr core:
Stdout: ${result.getStdout()}
Stderr:${result.getStderr()}

What it means

In the newer org.testcontainers.solr.SolrContainer, standalone (non-ZooKeeper) mode creates the core via `solr create -c <collection>` after startup. A non-zero exit code from that exec produces this IllegalStateException carrying the command's stdout and stderr.

Solutions

  1. Inspect Stdout/Stderr in the exception message for the underlying solr create failure.
  2. Ensure the configuration and schema files form a valid configset.
  3. Check the collection name for illegal characters.
  4. Enable ZooKeeper mode for SolrCloud-style collection handling.

Example fix

// before
ExecResult r = execInContainer("solr", "create", "-c", "");
// after
ExecResult r = execInContainer("solr", "create", "-c", "valid_core_name");
Defensive patterns

Strategy: try-catch

Validate before calling

if (name == null || !name.matches("[A-Za-z0-9_]+")) throw new IllegalArgumentException("invalid Solr core name: " + name);

Try / catch

try { container.start(); } catch (IllegalStateException e) { if (e.getMessage().contains("Unable to create solr core")) { log.error("solr create failed: {}", e.getMessage()); } throw e; }

Prevention

When it happens

Trigger: containerIsStarted runs the create-core exec and it fails — invalid collection name, existing core, broken uploaded configset, or Solr not ready to accept create requests.

Common situations: Custom configuration missing required files, duplicate withCollection names across tests reusing a container, or corrupted config mounted into the container.

Related errors


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

Appendix: source

Thrown at modules/solr/src/main/java/org/testcontainers/solr/SolrContainer.java:132

    }

    @Override
    public Set<Integer> getLivenessCheckPortNumbers() {
        return new HashSet<>(getSolrPort());
    }

    @Override
    protected void waitUntilContainerStarted() {
        getWaitStrategy().waitUntilReady(this);
    }

    @Override
    @SneakyThrows
    protected void containerIsStarted(InspectContainerResponse containerInfo) {
        if (!configuration.isZookeeper()) {
            ExecResult result = execInContainer("solr", "create", "-c", configuration.getCollectionName());
            if (result.getExitCode() != 0) {
                throw new IllegalStateException(
                    "Unable to create solr core:\nStdout: " + result.getStdout() + "\nStderr:" + result.getStderr()
                );
            }
            return;
        }

        if (StringUtils.isNotEmpty(configuration.getConfigurationName())) {
            SolrClientUtils.uploadConfiguration(
                getHost(),
                getSolrPort(),
                configuration.getConfigurationName(),
                configuration.getSolrConfiguration(),
                configuration.getSolrSchema()
            );
        }

        SolrClientUtils.createCollection(
            getHost(),

View on GitHub (pinned to 8e549514e3)