java-native-access/jna · error · RuntimeException
Unable to continue the service
Error message
Unable to continue the service
What it means
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.
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.
Example fix
// before
service.continueService();
// after
try {
service.continueService();
} catch (RuntimeException e) {
Winsvc.SERVICE_STATUS st = service.queryStatus();
if (st.dwCurrentState != Winsvc.SERVICE_RUNNING) {
service.stopService(30_000);
service.startService();
}
} Defensive patterns
Strategy: try-catch
Validate before calling
Winsvc.SERVICE_STATUS st = service.queryStatus();
if ((st.dwControlsAccepted & Winsvc.SERVICE_ACCEPT_PAUSE_CONTINUE) == 0)
throw new IllegalStateException("service does not support pause/continue"); Try / catch
try {
service.continueService();
} catch (RuntimeException e) {
Winsvc.SERVICE_STATUS st = service.queryStatus();
if (st.dwCurrentState != Winsvc.SERVICE_RUNNING) { /* stop/start recovery */ }
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Unable to pause the service
- Service stop exceeded timeout time of
- Timeout waiting for service to change to a non-pending…
- Could not set proxy blanket.
- DACL is invalid
AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12).
Data as JSON: /api/errors/c6cc8319366f7f53.
Report an issue: GitHub.
Appendix: source
Thrown at contrib/platform/src/com/sun/jna/platform/win32/W32Service.java:275
}
}
/**
* Continue service.
*/
public void continueService() {
waitForNonPendingState();
// If the service is already stopped - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_RUNNING) {
return;
}
if (!Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_CONTINUE,
new Winsvc.SERVICE_STATUS())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_RUNNING) {
throw new RuntimeException("Unable to continue the service");
}
}
/**
* Pause service.
*/
public void pauseService() {
waitForNonPendingState();
// If the service is already paused - return
if (queryStatus().dwCurrentState == Winsvc.SERVICE_PAUSED) {
return;
}
if (!Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_PAUSE,
new Winsvc.SERVICE_STATUS())) {
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
}
waitForNonPendingState();
if (queryStatus().dwCurrentState != Winsvc.SERVICE_PAUSED) {View on GitHub (pinned to d036ad9781)