{"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/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/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() raises MalformedURLException, wrapped as IllegalStateException. toURL is used while building the classpath/dependency URLs for filtering mojos. In practice File.toURI() almost never yields a malformed URL, so this typically signals an exotic filesystem path or a degenerate File value.","triggerScenarios":"getDependencyURLs()/getClassPath() iterates project artifacts or directories and calls toURL(artifact.getFile()); if file.toURI().toURL() throws MalformedURLException, line 142 raises IllegalStateException(\"Invalid URL for \" + file).","commonSituations":"An artifact whose resolved File is null-ish/unusual (rare); a path containing characters that the URI converter rejects on some JVMs; a custom artifact resolver returning a non-standard File; filesystem-specific oddities.","solutions":["Inspect the file value named in the message and confirm the artifact resolved to a real path.","Run mvn dependency:tree / dependency:resolve to ensure all artifacts resolve to valid files.","Clear the local Maven repo for the offending artifact and re-resolve.","If a custom/resolved File is involved, ensure it represents an absolute, well-formed path."],"exampleFix":"// shell: re-resolve a suspect artifact\n//   rm -rf ~/.m2/repository/<group-path>/<artifact>\n//   mvn dependency:resolve\n","handlingStrategy":"try-catch","validationCode":"// Validate that all resolved artifacts map to readable, well-formed files\nproject.artifacts.forEach { art ->\n    val f = art.file\n    require(f != null && f.isAbsolute && f.canRead()) {\n        \"Artifact ${art} resolved to invalid file ${f}\"\n    }\n    // toURI must not throw\n    try { f.toURI().toURL() } catch (e: java.net.MalformedURLException) {\n        throw IllegalArgumentException(\"Artifact ${art} has invalid URL form\", e)\n    }\n}\n","typeGuard":null,"tryCatchPattern":"try {\n    // mojo goal that resolves dependencies\n} catch (ex: IllegalStateException) {\n    if (ex.message?.startsWith(\"Invalid URL for \") == true) {\n        project.logger.error(\"An artifact resolved to an invalid file path; re-resolve dependencies.\")\n    }\n    throw ex\n}\n","preventionTips":["Run mvn dependency:resolve to confirm all artifacts map to real files.","Clear ~/.m2/repository entries for artifacts that fail to resolve cleanly.","Avoid custom artifact resolvers that produce non-standard File values."],"tags":["maven","dependencies","classpath","url","io"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}