{"record":{"id":"ee0b14bb6f63b5c2","repo":"microsoft/aspire","slug":"java-application-resource-name-cannot-be-published-because-ee0b14","errorCode":null,"errorMessage":"Java application '{resource.Name}' cannot be published because the wrapper configured with WithWrapperPath was not found at '{resolvedWrapperPath}'.","messagePattern":"Java application '(.+?)' cannot be published because the wrapper configured with WithWrapperPath was not found at '(.+?)'\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Java/JavaDockerfileGenerator.cs","lineNumber":1056,"sourceCode":"            // script that the build stage cannot execute.\n            var resolvedWrapperPath = JavaBuildToolResolver.ResolveWrapperPath(resource, tool, isWindows: false);\n            var isConfigured = resource.HasAnnotationOfType<WrapperAnnotation>();\n            var relative = Path.GetRelativePath(appDirectory, resolvedWrapperPath).Replace('\\\\', '/');\n\n            if (relative.StartsWith(\"../\", StringComparison.Ordinal) || IsPathRootedOnAnyPlatform(relative))\n            {\n                throw new DistributedApplicationException(\n                    $\"Java application '{resource.Name}' cannot be published because its wrapper \" +\n                    $\"'{resolvedWrapperPath}' is outside the build context '{appDirectory}'. \" +\n                    \"Move the wrapper into the application directory, or set the build context to a \" +\n                    \"directory that contains both.\");\n            }\n\n            if (!File.Exists(resolvedWrapperPath))\n            {\n                if (isConfigured)\n                {\n                    throw new DistributedApplicationException(\n                        $\"Java application '{resource.Name}' cannot be published because the wrapper \" +\n                        $\"configured with WithWrapperPath was not found at '{resolvedWrapperPath}'.\");\n                }\n\n                var defaultWrapperName = JavaBuildToolResolver.GetDefaultWrapperName(tool, isWindows: false);\n                throw new DistributedApplicationException(\n                    $\"Java application '{resource.Name}' cannot be published because there is no \" +\n                    $\"{defaultWrapperName} in '{appDirectory}'. Aspire builds the image with the project's \" +\n                    $\"own wrapper so the container uses the tool version the repository pins. Generate one \" +\n                    $\"with {JavaHostingExtensions.GenerateWrapperCommand(tool)}, or point at an existing \" +\n                    \"wrapper with WithWrapperPath.\");\n            }\n\n            // The build stage is Linux, so a Windows batch wrapper cannot run there even though it is\n            // the right choice on the developer's machine. Maven and Gradle ship the POSIX script\n            // alongside the batch one under the same base name, so prefer that sibling and only fail\n            // when it is genuinely absent.\n            // https://maven.apache.org/wrapper/ and https://docs.gradle.org/current/userguide/gradle_wrapper.html","sourceCodeStart":1038,"sourceCodeEnd":1074,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Java/JavaDockerfileGenerator.cs#L1038-L1074","documentation":"During publish, the wrapper path explicitly configured via WithWrapperPath does not exist on disk. Aspire validates the configured wrapper before emitting the Dockerfile so the failure is named at publish time rather than surfacing as a Docker build error. It is thrown only when the wrapper was explicitly configured (WrapperAnnotation present), distinguishing user error from the missing-default-wrapper case.","triggerScenarios":"Publishing an AddJavaApp resource after calling WithWrapperPath(\"<path>\") where that file does not exist at the resolved path (typo, wrong relative base, file deleted, or the wrapper was never generated).","commonSituations":"Typo in the wrapper filename; passing a directory instead of the script; wrapper generated on another machine/OS and not committed; repo cloned without the wrapper because .gitignore excluded it; resolving relative to a different current directory than expected.","solutions":["Correct the path passed to WithWrapperPath so it points at the existing wrapper script.","Generate the wrapper with the documented command (e.g. mvn wrapper:wrapper or gradle wrapper) inside the app directory.","Verify the file exists on disk at the exact resolved path before publishing."],"exampleFix":"// before\n.WithWrapperPath(\"mvnw.sh\") // file is actually named 'mvnw'\n// after\n.WithWrapperPath(\"mvnw\");","handlingStrategy":"validation","validationCode":"var wrapper = \"src/Api/mvnw\";\nif (!File.Exists(wrapper))\n    throw new FileNotFoundException($\"Configured wrapper missing: {wrapper}\");","typeGuard":null,"tryCatchPattern":"try { /* publish */ }\ncatch (DistributedApplicationException ex) when (ex.Message.Contains(\"WithWrapperPath was not found\"))\n{ /* fix or generate the wrapper, then republish */ }","preventionTips":["Verify the wrapper file exists on disk before calling WithWrapperPath","Commit wrapper scripts (and .mvn/ or gradle/wrapper dirs) to source control","Use paths relative to the app directory consistently"],"tags":["java","file-not-found","publish","wrapper"],"backgroundTag":"file-not-found","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"}