{"record":{"id":"5d40ab85a5edb820","repo":"microsoft/aspire","slug":"java-application-resource-name-cannot-be-published-because-5d40ab","errorCode":null,"errorMessage":"Java application '{resource.Name}' cannot be published because its wrapper path '{relative}' contains whitespace, which a Dockerfile COPY instruction cannot express. Move the wrapper to a path without spaces.","messagePattern":"Java application '(.+?)' cannot be published because its wrapper path '(.+?)' contains whitespace, which a Dockerfile COPY instruction cannot express\\. Move the wrapper to a path without spaces\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Java/JavaDockerfileGenerator.cs","lineNumber":1097,"sourceCode":"                if (!File.Exists(Path.Combine(appDirectory, posixSibling.Replace('/', Path.DirectorySeparatorChar))))\n                {\n                    throw new DistributedApplicationException(\n                        $\"Java application '{resource.Name}' cannot be published because its wrapper \" +\n                        $\"'{relative}' is a Windows batch script and the container build stage is Linux. \" +\n                        $\"No '{posixSibling}' was found next to it. Generate the wrapper with \" +\n                        $\"{JavaHostingExtensions.GenerateWrapperCommand(tool)} so both scripts are present.\");\n                }\n\n                relative = posixSibling;\n            }\n\n            // A Dockerfile COPY takes its arguments separated by whitespace and has no quoted form here,\n            // so a wrapper path containing whitespace would copy two nonexistent paths instead of one real\n            // one. Rejecting it names the problem, rather than failing later inside the build with \"no such\n            // file or directory\" for a path the author never wrote.\n            if (relative.Any(char.IsWhiteSpace))\n            {\n                throw new DistributedApplicationException(\n                    $\"Java application '{resource.Name}' cannot be published because its wrapper path \" +\n                    $\"'{relative}' contains whitespace, which a Dockerfile COPY instruction cannot \" +\n                    \"express. Move the wrapper to a path without spaces.\");\n            }\n\n            return relative;\n        }\n\n        internal static (JavaBuildTool Tool, string[] Args) ResolveToolAndArgs(JavaAppResource resource, string appDirectory)\n        {\n            var (tool, args) = ResolveConfiguredToolAndArgs(resource, appDirectory);\n\n            return (tool, WithoutGradleDaemon(tool, args));\n        }\n\n        /// <summary>\n        /// Adds <c>--no-daemon</c> to a Gradle invocation that does not already carry it.\n        /// </summary>","sourceCodeStart":1079,"sourceCodeEnd":1115,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Java/JavaDockerfileGenerator.cs#L1079-L1115","documentation":"The wrapper's path relative to the build context contains whitespace. A Dockerfile COPY instruction separates its arguments by whitespace and this generator does not emit a quoted form, so a spaced path would copy two wrong paths. Aspire rejects it at publish time with a clear message instead of an opaque 'no such file or directory' inside the Docker build.","triggerScenarios":"Publishing a Java app whose wrapper resolves to a relative path containing a space, e.g. the app lives in 'My Project/Api' or WithWrapperPath points into a folder like 'build tools/mvnw'.","commonSituations":"Solution folders with spaces ('Visual Studio Projects', 'My App'); cloning repos into directories with spaces; wrapper placed under a directory named with spaces inside the context.","solutions":["Move the wrapper (and ideally the whole app) to a path without spaces within the build context.","Rename the containing directory to remove spaces (e.g. 'MyProject' instead of 'My Project').","Restructure so the build context directory itself and its path to the wrapper contain no whitespace."],"exampleFix":"// before\nbuilder.AddJavaApp(\"api\", \"My Project/Api\"); // wrapper at 'My Project/Api/mvnw'\n// after\nbuilder.AddJavaApp(\"api\", \"MyProject/Api\"); // rename folder to remove the space","handlingStrategy":"validation","validationCode":"var relative = Path.GetRelativePath(context, wrapper);\nif (relative.Any(char.IsWhiteSpace))\n    throw new Exception($\"Wrapper path '{relative}' must not contain whitespace\");","typeGuard":null,"tryCatchPattern":"try { /* publish */ }\ncatch (DistributedApplicationException ex) when (ex.Message.Contains(\"contains whitespace\"))\n{ /* relocate wrapper/app to a space-free path, then republish */ }","preventionTips":["Place projects under space-free directories (avoid 'My Project', 'Visual Studio Projects')","Adopt a team convention of no spaces in repo or build paths","Check clone/target directories for spaces before configuring Aspire apps"],"tags":["java","dockerfile","whitespace","path"],"backgroundTag":"invalid-argument-format","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}