{"record":{"id":"c6cc8319366f7f53","repo":"java-native-access/jna","slug":"unable-to-continue-the-service","errorCode":null,"errorMessage":"Unable to continue the service","messagePattern":"Unable to continue the service","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"contrib/platform/src/com/sun/jna/platform/win32/W32Service.java","lineNumber":275,"sourceCode":"        }\n    }\n\n    /**\n     * Continue service.\n     */\n    public void continueService() {\n        waitForNonPendingState();\n        // If the service is already stopped - return\n        if (queryStatus().dwCurrentState == Winsvc.SERVICE_RUNNING) {\n            return;\n        }\n        if (!Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_CONTINUE,\n                new Winsvc.SERVICE_STATUS())) {\n            throw new Win32Exception(Kernel32.INSTANCE.GetLastError());\n        }\n        waitForNonPendingState();\n        if (queryStatus().dwCurrentState != Winsvc.SERVICE_RUNNING) {\n            throw new RuntimeException(\"Unable to continue the service\");\n        }\n    }\n\n    /**\n     * Pause service.\n     */\n    public void pauseService() {\n        waitForNonPendingState();\n        // If the service is already paused - return\n        if (queryStatus().dwCurrentState == Winsvc.SERVICE_PAUSED) {\n            return;\n        }\n        if (!Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_PAUSE,\n                new Winsvc.SERVICE_STATUS())) {\n            throw new Win32Exception(Kernel32.INSTANCE.GetLastError());\n        }\n        waitForNonPendingState();\n        if (queryStatus().dwCurrentState != Winsvc.SERVICE_PAUSED) {","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/java-native-access/jna/blob/d036ad9781adad4b66693e8fa7098e4ac665e0a3/contrib/platform/src/com/sun/jna/platform/win32/W32Service.java#L257-L293","documentation":"continueService() sends SERVICE_CONTROL_CONTINUE, waits for the service to leave a pending state, and then re-queries the status. If the resulting state is not SERVICE_RUNNING, the library throws this RuntimeException because the resume attempt silently failed at the SCM level.","triggerScenarios":"Calling continueService() on a Windows service that accepts the CONTINUE control but ends in a state other than RUNNING (e.g. it returns to PAUSED or STOPPED after resuming), or on a service whose resume path fails internally.","commonSituations":"Services that do not truly support pause/continue (report SERVICE_ACCEPT_PAUSE_CONTINUE but fail on resume); a service crashes or stops during resume; racing with another control request that changed the final state.","solutions":["Verify the service actually supports pause/continue (check AcceptedControls / sc qfailure flags) before calling continueService.","Inspect the Windows Event Log for service-side errors explaining why resume failed.","Catch the RuntimeException, re-query the status, and decide whether to stop/start the service instead of resuming.","Ensure only one control thread issues pause/continue commands at a time."],"exampleFix":"// before\nservice.continueService();\n// after\ntry {\n    service.continueService();\n} catch (RuntimeException e) {\n    Winsvc.SERVICE_STATUS st = service.queryStatus();\n    if (st.dwCurrentState != Winsvc.SERVICE_RUNNING) {\n        service.stopService(30_000);\n        service.startService();\n    }\n}","handlingStrategy":"try-catch","validationCode":"Winsvc.SERVICE_STATUS st = service.queryStatus();\nif ((st.dwControlsAccepted & Winsvc.SERVICE_ACCEPT_PAUSE_CONTINUE) == 0)\n    throw new IllegalStateException(\"service does not support pause/continue\");","typeGuard":null,"tryCatchPattern":"try {\n    service.continueService();\n} catch (RuntimeException e) {\n    Winsvc.SERVICE_STATUS st = service.queryStatus();\n    if (st.dwCurrentState != Winsvc.SERVICE_RUNNING) { /* stop/start recovery */ }\n}","preventionTips":["Verify pause/continue support via ControlsAccepted before issuing controls.","Serialize service control operations in one thread.","Inspect Event Viewer after any failed resume to find service-side causes."],"tags":["windows","service","state"],"backgroundTag":"invalid-state-transition","analyzedSha":"d036ad9781adad4b66693e8fa7098e4ac665e0a3","analyzedAt":"2026-09-12T06:50:59.239Z","contentChangedAt":"2026-09-12T06:50:59.239Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}