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

After a non-ZooKeeper (standalone) Solr container starts, SolrContainer runs `solr create -c <collection>` inside the container to create the core. If that command exits non-zero, the stdout/stderr of the failure is wrapped in this IllegalStateException.

Solutions

  1. Read the Stdout/Stderr in the message: it names the real cause (bad config, duplicate core, etc.).
  2. Verify the configuration/schema URLs point to valid, complete files.
  3. Use a valid collection name (alphanumeric and underscores only).
  4. Use ZooKeeper mode if you need cluster-aware core/collection creation.

Example fix

// before
container.withCollection("my collection");
// after
container.withCollection("my_collection");
Defensive patterns

Strategy: try-catch

Validate before calling

if (container.getCollectionName() == null || container.getCollectionName().isEmpty()) throw new IllegalArgumentException("collection name required");

Try / catch

try { container.start(); } catch (IllegalStateException e) { if (e.getMessage().startsWith("Unable to create solr core")) { /* inspect stdout/stderr, check configset + collection name */ } throw e; }

Prevention

When it happens

Trigger: containerIsStarted executes `solr create -c <name>` and the exit code is != 0 — e.g. the core name is invalid, a core with that name already exists, or Solr hasn't finished booting.

Common situations: Custom configuration uploaded without the schema file, malformed solrconfig.xml, collection names with illegal characters, or slow disk causing Solr to reject early create requests.

Related errors


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

Appendix: source

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

    }

    @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)