{"record":{"id":"edd44c80ecff5f98","repo":"perwendel/spark","slug":"external-static-file-location-has-already-been-set","errorCode":null,"errorMessage":"External static file location has already been set","messagePattern":"External static file location has already been set","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/main/java/spark/Service.java","lineNumber":366,"sourceCode":"        return this;\n    }\n\n    /**\n     * Sets the external folder serving static files. <b>Observe: this method\n     * must be called before all other methods.</b>\n     *\n     * @param externalFolder the external folder serving static files.\n     * @return the object with external folder set\n     */\n    public synchronized Service externalStaticFileLocation(String externalFolder) {\n        if (initialized && !isRunningFromServlet()) {\n            throwBeforeRouteMappingException();\n        }\n\n        if (!staticFilesConfiguration.isExternalStaticResourcesSet()) {\n            staticFilesConfiguration.configureExternal(externalFolder);\n        } else {\n            LOG.warn(\"External static file location has already been set\");\n        }\n        return this;\n    }\n\n    /**\n     * Unmaps a particular route from the collection of those that have been previously routed.\n     * Search for previously established routes using the given path and unmaps any matches that are found.\n     *\n     * @param path the route path\n     * @return <tt>true</tt> if this is a matching route which has been previously routed\n     * @throws IllegalArgumentException if <tt>path</tt> is null or blank\n     */\n    public boolean unmap(String path) {\n        return routes.remove(path);\n    }\n\n    /**\n     * Unmaps a particular route from the collection of those that have been previously routed.","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/perwendel/spark/blob/1973e402f5d4c1442ad34a1d38ed0758079f7773/src/main/java/spark/Service.java#L348-L384","documentation":"Service.externalStaticFileLocation logs 'External static file location has already been set' and skips reconfiguration when the external static resources were already configured. The second folder is silently ignored, so files from the new external folder are never served.","triggerScenarios":"Calling externalStaticFileLocation(...) twice, or after another call already invoked staticFilesConfiguration.configureExternal; calling it after static resources were already set up elsewhere during init.","commonSituations":"Multiple init() code paths both configuring external folders; deployment scripts injecting a different folder while code also sets one; duplicated bootstrap code between dev and prod config classes.","solutions":["Configure the external folder exactly once during service init, before route mapping.","Remove or guard the duplicate externalStaticFileLocation call (the warning points at the second call site).","If the folder must change, create a new Service instance or restructure configuration instead of re-calling the method.","Centralize static-file configuration in one place to prevent divergent init paths."],"exampleFix":"// before\nservice.externalStaticFileLocation(\"/var/www\");\nservice.externalStaticFileLocation(\"/opt/assets\"); // ignored, warns\n// after\nservice.externalStaticFileLocation(\"/opt/assets\"); // single authoritative call","handlingStrategy":"validation","validationCode":"if (!externalStaticConfigured) {\n    service.externalStaticFileLocation(\"/opt/assets\");\n    externalStaticConfigured = true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure the external folder exactly once during service bootstrap.","Centralize static-file configuration instead of spreading it across config classes.","Ensure deployment tooling and code do not both set the external folder.","Watch startup logs for the 'already been set' warning to catch duplicate calls."],"tags":["configuration","static-files","duplicate-config"],"backgroundTag":"conflicting-config-options","analyzedSha":"1973e402f5d4c1442ad34a1d38ed0758079f7773","analyzedAt":"2026-09-10T14:38:22.866Z","contentChangedAt":"2026-09-10T14:38:22.866Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}