{"record":{"id":"17a70b84e6ae7fe1","repo":"testcontainers/testcontainers-java","slug":"solr-needs-to-have-a-configuration-if-you-want-to-use-a-17a70b","errorCode":null,"errorMessage":"Solr needs to have a configuration if you want to use a schema","messagePattern":"Solr needs to have a configuration if you want to use a schema","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/solr/src/main/java/org/testcontainers/solr/SolrContainer.java","lineNumber":95,"sourceCode":"\n    public SolrContainer withSchema(URL schema) {\n        configuration.setSolrSchema(schema);\n        return self();\n    }\n\n    public int getSolrPort() {\n        return getMappedPort(SOLR_PORT);\n    }\n\n    public int getZookeeperPort() {\n        return getMappedPort(ZOOKEEPER_PORT);\n    }\n\n    @Override\n    @SneakyThrows\n    protected void configure() {\n        if (configuration.getSolrSchema() != null && configuration.getSolrConfiguration() == null) {\n            throw new IllegalStateException(\"Solr needs to have a configuration if you want to use a schema\");\n        }\n        // Generate Command Builder\n        String command = \"solr start -f\";\n        // Add Default Ports\n        addExposedPort(SOLR_PORT);\n\n        // Configure Zookeeper\n        if (configuration.isZookeeper()) {\n            addExposedPort(ZOOKEEPER_PORT);\n            if (this.imageVersion.isGreaterThanOrEqualTo(\"9.7.0\")) {\n                command = \"-DzkRun --host localhost\";\n            } else {\n                command = \"-DzkRun -h localhost\";\n            }\n        }\n\n        // Apply generated Command\n        setCommand(command);","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/solr/src/main/java/org/testcontainers/solr/SolrContainer.java#L77-L113","documentation":"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.","triggerScenarios":"org.testcontainers.solr.SolrContainer started after calling withSchema(...) without withConfiguration(...).","commonSituations":"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.","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."],"exampleFix":"// before\nnew org.testcontainers.solr.SolrContainer(\"solr:9\")\n    .withSchema(schemaUrl);\n// after\nnew org.testcontainers.solr.SolrContainer(\"solr:9\")\n    .withConfiguration(\"custom\", solrConfigUrl)\n    .withSchema(schemaUrl);","handlingStrategy":"validation","validationCode":"assert schemaUrl == null || configUrl != null : \"a schema requires a solrconfig.xml configuration\";","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["solr","testcontainers","configuration"],"backgroundTag":"conflicting-config-options","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}