{"record":{"id":"5e11bb3a9faa5abb","repo":"jenkinsci/jenkins","slug":"jenkins-war-location-is-not-known-5e11bb","errorCode":null,"errorMessage":"jenkins.war location is not known.","messagePattern":"jenkins\\.war location is not known\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java","lineNumber":101,"sourceCode":"                    LOGGER.log(Level.SEVERE, \"Failed to replace \" + name, e);\n                } catch (InterruptedException e) {\n                }\n            }\n        } catch (IOException e) {\n            LOGGER.log(Level.SEVERE, \"Failed to replace jenkins.exe\", e);\n        }\n    }\n\n    /**\n     * On Windows, jenkins.war is locked, so we place a new version under a special name,\n     * which is picked up by the service wrapper upon restart.\n     */\n    @Override\n    public void rewriteHudsonWar(File by) throws IOException {\n        File dest = getHudsonWar();\n        // this should be impossible given the canRewriteHudsonWar method,\n        // but let's be defensive\n        if (dest == null)  throw new IOException(\"jenkins.war location is not known.\");\n\n        // backing up the old jenkins.war before its lost due to upgrading\n        // unless we are trying to rewrite jenkins.war by a backup itself\n        File bak = new File(dest.getPath() + \".bak\");\n        if (!by.equals(bak))\n            FileUtils.copyFile(dest, bak);\n\n        String baseName = dest.getName();\n        baseName = baseName.substring(0, baseName.indexOf('.'));\n\n        File baseDir = getBaseDir();\n        File copyFiles = new File(baseDir, baseName + \".copies\");\n\n        try (Writer w = Files.newBufferedWriter(Util.fileToPath(copyFiles), Charset.defaultCharset(), StandardOpenOption.CREATE, StandardOpenOption.APPEND)) {\n            w.write(by.getAbsolutePath() + '>' + getHudsonWar().getAbsolutePath() + '\\n');\n        }\n    }\n","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/lifecycle/WindowsServiceLifecycle.java#L83-L119","documentation":"Thrown by WindowsServiceLifecycle.rewriteHudsonWar(File) when getHudsonWar() returns null. Identical defensive guard as the base Lifecycle.rewriteHudsonWar, but in the Windows context the war is locked while the service runs, so the method writes the new war to a special name (.copies mechanism) for the service wrapper to pick up on restart. A null war path short-circuits before that mechanism runs.","triggerScenarios":"Jenkins running as a Windows service; an upgrade path calls rewriteHudsonWar(by); getHudsonWar() returns null because the war location is not resolvable in this service deployment.","commonSituations":"Service installed in a non-standard layout where the war path is not registered; custom service wrapper that does not expose the war location; a repackaged war deployed under a different name.","solutions":["Verify the Jenkins service is installed from the standard jenkins.war so the path is resolvable","Check the service wrapper configuration (jenkins.xml) for the correct war path","Perform upgrades via the service wrapper's own mechanism rather than the in-process rewrite API","Ensure getHudsonWar() returns non-null by launching from the actual war file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Lifecycle lc = Lifecycle.get();\nif (lc.getHudsonWar() == null) {\n    throw new IllegalStateException(\"jenkins.war not resolvable in this Windows service deployment\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    Lifecycle.get().rewriteHudsonWar(newWar);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"jenkins.war location is not known\")) {\n        // redeploy via the service wrapper instead\n    }\n    throw e;\n}","preventionTips":["Install the Windows service from the standard jenkins.war","Keep the service wrapper config (jenkins.xml) pointing at the real war path","Use the service wrapper's upgrade mechanism rather than in-process rewrite"],"tags":["lifecycle","windows","war-location","upgrade","service"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}