{"record":{"id":"d64326f4fe5ebb8b","repo":"spring-projects/spring-boot","slug":"invalid-url-for","errorCode":null,"errorMessage":"Invalid URL for {}","messagePattern":"Invalid URL for (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractDependencyFilterMojo.java","lineNumber":142,"sourceCode":"\n\tprotected final Set<Artifact> filterDependencies(Set<Artifact> dependencies, ArtifactsFilter... additionalFilters)\n\t\t\tthrows MojoExecutionException {\n\t\ttry {\n\t\t\tSet<Artifact> filtered = new LinkedHashSet<>(dependencies);\n\t\t\tfiltered.retainAll(getFilters(additionalFilters).filter(dependencies));\n\t\t\treturn filtered;\n\t\t}\n\t\tcatch (ArtifactFilterException ex) {\n\t\t\tthrow new MojoExecutionException(ex.getMessage(), ex);\n\t\t}\n\t}\n\n\tprotected URL toURL(File file) {\n\t\ttry {\n\t\t\treturn file.toURI().toURL();\n\t\t}\n\t\tcatch (MalformedURLException ex) {\n\t\t\tthrow new IllegalStateException(\"Invalid URL for \" + file, ex);\n\t\t}\n\t}\n\n\t/**\n\t * Return artifact filters configured for this MOJO.\n\t * @param additionalFilters optional additional filters to apply\n\t * @return the filters\n\t */\n\tprivate FilterArtifacts getFilters(ArtifactsFilter... additionalFilters) {\n\t\tFilterArtifacts filters = new FilterArtifacts();\n\t\tfor (ArtifactsFilter additionalFilter : additionalFilters) {\n\t\t\tfilters.addFilter(additionalFilter);\n\t\t}\n\t\tfilters.addFilter(new MatchingGroupIdFilter(cleanFilterConfig(this.excludeGroupIds)));\n\t\tif (this.includes != null && !this.includes.isEmpty()) {\n\t\t\tfilters.addFilter(new IncludeFilter(this.includes));\n\t\t}\n\t\tif (this.excludes != null && !this.excludes.isEmpty()) {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractDependencyFilterMojo.java#L124-L160","documentation":"Thrown by AbstractDependencyFilterMojo.toURL when File.toURI().toURL() throws a MalformedURLException. This helper converts a File to a URL for classpath assembly. In practice File.toURI().toURL() almost never throws (URI.toURL only fails on non-absolute or non-URL-compatible URIs), so this is a defensive guard for pathological file paths. The IllegalStateException wraps the original MalformedURLException with the offending File.","triggerScenarios":"Passing a File to toURL whose path, when converted to a URI, yields a non-absolute or otherwise URL-incompatible URI. This is invoked by getClassPath and getDependencyURLs when building the runtime/compile classpath for filtering in the Maven plugin.","commonSituations":"A dependency artifact resolved to a path with characters that break URI-to-URL conversion (extremely rare since toURI normalizes). A File object constructed from a relative path that does not normalize to absolute. A repository path containing characters outside the legal URL set. Custom ArtifactResolver or local repository layouts producing odd paths. Essentially never fires in standard Maven usage.","solutions":["Inspect the 'file' value in the message: if it is a relative path, ensure artifacts resolve to absolute paths.","Check the local Maven repository (~/.m2/repository) for corrupted or oddly-named artifact paths and re-resolve with 'mvn dependency:purge-local-repository'.","Verify no custom artifact factory or local-repository layout is producing non-URL-compatible paths.","As a last resort, run 'mvn clean package -X' and inspect the artifact paths in the debug log."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-validate that artifact files convert to URLs cleanly.\nfor (File f : directories) {\n    if (!f.isAbsolute()) f = f.getAbsoluteFile();\n    try {\n        f.toURI().toURL();\n    } catch (MalformedURLException ex) {\n        throw new IllegalArgumentException(\"Cannot convert to URL: \" + f, ex);\n    }\n}","typeGuard":null,"tryCatchPattern":"// Catch IllegalStateException and surface the offending file.\ntry {\n    mojo.toURL(artifactFile);\n} catch (IllegalStateException ex) {\n    // 'file' value is in the message — re-resolve the artifact\n    artifact = mavenResolver.resolveArtifact(artifactCoords);\n}","preventionTips":["Use absolute file paths for artifact references.","Run 'mvn dependency:purge-local-repository' if local repo paths look corrupted.","Avoid custom local-repository layouts that produce non-URL-compatible paths."],"tags":["maven","url","classpath","dependency","spring-boot-plugin","filesystem"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}