testcontainers/testcontainers-java · error · IllegalStateException
Solr needs to have a configuration if you want to use a…
Error message
Solr needs to have a configuration if you want to use a schema
What it means
Same check as the deprecated modules/solr SolrContainer: a schema requires a configuration (solrconfig.xml) since Solr cores are created from a configset containing both. Thrown from configure() during container startup when the schema is set but the configuration is not.
Solutions
- Call withConfiguration(name, url-to-solrconfig.xml) before withSchema.
- Drop the schema override and rely on the _default configset if custom solrconfig isn't needed.
- Package schema.xml and solrconfig.xml together as a configset.
Example fix
// before
new org.testcontainers.solr.SolrContainer("solr:9")
.withSchema(schemaUrl);
// after
new org.testcontainers.solr.SolrContainer("solr:9")
.withConfiguration("custom", solrConfigUrl)
.withSchema(schemaUrl); Defensive patterns
Strategy: validation
Validate before calling
assert schemaUrl == null || configUrl != null : "a schema requires a solrconfig.xml configuration";
Prevention
- Ship a single configset directory (solrconfig.xml + schema.xml) and wire both in one builder call.
- Keep a project-wide Solr container factory to enforce the pairing.
When it happens
Trigger: org.testcontainers.solr.SolrContainer started after calling withSchema(...) without withConfiguration(...).
Common situations: Migrating from the old module and copying only the schema-related builder calls; assuming a default solrconfig is auto-supplied when only the schema is customized.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Solr needs to have a configuration if you want to use a…
- Changing startup timeout is not supported with mode
- Unexpected scheme
- Setting a in not supported in the versions below 22.1.0
- The provided service (service) has no quota to configure
AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12).
Data as JSON: /api/errors/17a70b84e6ae7fe1.
Report an issue: GitHub.
Appendix: source
Thrown at modules/solr/src/main/java/org/testcontainers/solr/SolrContainer.java:95
public SolrContainer withSchema(URL schema) {
configuration.setSolrSchema(schema);
return self();
}
public int getSolrPort() {
return getMappedPort(SOLR_PORT);
}
public int getZookeeperPort() {
return getMappedPort(ZOOKEEPER_PORT);
}
@Override
@SneakyThrows
protected void configure() {
if (configuration.getSolrSchema() != null && configuration.getSolrConfiguration() == null) {
throw new IllegalStateException("Solr needs to have a configuration if you want to use a schema");
}
// Generate Command Builder
String command = "solr start -f";
// Add Default Ports
addExposedPort(SOLR_PORT);
// Configure Zookeeper
if (configuration.isZookeeper()) {
addExposedPort(ZOOKEEPER_PORT);
if (this.imageVersion.isGreaterThanOrEqualTo("9.7.0")) {
command = "-DzkRun --host localhost";
} else {
command = "-DzkRun -h localhost";
}
}
// Apply generated Command
setCommand(command);View on GitHub (pinned to 8e549514e3)