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
- Read the Stdout/Stderr in the message: it names the real cause (bad config, duplicate core, etc.).
- Verify the configuration/schema URLs point to valid, complete files.
- Use a valid collection name (alphanumeric and underscores only).
- 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
- Use simple alphanumeric collection names.
- Validate solrconfig.xml/schema.xml locally before mounting them.
- Read the embedded Stdout/Stderr before guessing at fixes.
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
- Unable to create solr core: Stdout
- Solr needs to have a configuration if you want to use a…
- Collection name must not be empty
- Solr needs to have a configuration if you want to use a…
- HTTP response code was
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)