java-native-access/jna · error · com.sun.jna.platform.win32.COM.COMException
Failed to enumerate results.
Error message
Failed to enumerate results.
What it means
In enumerateProperties, any HRESULT from IEnumWbemClassObject::Next that is not WBEM_S_FALSE / WBEM_S_NO_MORE_DATA / WBEM_S_TIMEDOUT and indicates failure (COMUtils.FAILED) produces this COMException, wrapping the HRESULT for diagnostics.
Source
Thrown at contrib/platform/src/com/sun/jna/platform/win32/COM/WbemcliUtil.java:311
HRESULT hres = null;
for (T property : propertyEnum.getEnumConstants()) {
wstrMap.put(property, new WString(property.name()));
}
while (enumerator.getPointer() != Pointer.NULL) {
// Enumerator will be released by calling method so no need to
// release it here.
hres = enumerator.Next(timeout, pclsObj.length, pclsObj, uReturn);
// Enumeration complete or no more data; we're done, exit the loop
if (hres.intValue() == Wbemcli.WBEM_S_FALSE || hres.intValue() == Wbemcli.WBEM_S_NO_MORE_DATA) {
break;
}
// Throw exception to notify user of timeout
if (hres.intValue() == Wbemcli.WBEM_S_TIMEDOUT) {
throw new TimeoutException("No results after " + timeout + " ms.");
}
// Other exceptions here.
if (COMUtils.FAILED(hres)) {
throw new COMException("Failed to enumerate results.", hres);
}
VARIANT.ByReference pVal = new VARIANT.ByReference();
IntByReference pType = new IntByReference();
// Get the value of the properties
IWbemClassObject clsObj = new IWbemClassObject(pclsObj[0]);
for (T property : propertyEnum.getEnumConstants()) {
clsObj.Get(wstrMap.get(property), 0, pVal, pType, null);
int vtType = (pVal.getValue() == null ? Variant.VT_NULL : pVal.getVarType()).intValue();
int cimType = pType.getValue();
switch (vtType) {
case Variant.VT_BSTR:
values.add(vtType, cimType, property, pVal.stringValue());
break;
case Variant.VT_I4:
values.add(vtType, cimType, property, pVal.intValue());
break;View on GitHub (pinned to d036ad9781)
Solutions
- Inspect the HRESULT inside the COMException (getHresult()) and match it against Wbemcli constants to find the specific cause.
- Run winmgmt /verifyrepository and rebuild the WMI repository if corrupt.
- Check permissions on the WMI namespace (e.g. wmimgmt.msc -> WMI Control -> Security).
- Simplify the query and test with wbemtest or PowerShell Get-WmiObject to isolate provider failures.
Example fix
// before
try { result = query.execute(); } catch (COMException e) { throw e; }
// after
try {
result = query.execute();
} catch (COMException e) {
log.error("WMI enumerate failed, hresult=0x{}", Integer.toHexString(e.getHresult().intValue()), e);
throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try {
result = query.execute();
} catch (COMException e) {
int hres = e.getHresult() != null ? e.getHresult().intValue() : -1;
switch (hres) {
case Wbemcli.WBEM_E_ACCESS_DENIED: /* fix namespace permissions */ break;
case Wbemcli.WBEM_E_INVALID_QUERY: /* fix WQL */ break;
default: /* repository/provider failure */
}
} Prevention
- Log the wrapped HRESULT for every COMException
- Validate WQL with wbemtest/PowerShell first
- Check WMI namespace security for the invoking user
When it happens
Trigger: The WMI enumerator returns a failing HRESULT — e.g. WBEM_E_FAILED, WBEM_E_INVALID_QUERY, WBEM_E_ACCESS_DENIED, or WBEM_E_NOT_SUPPORTED from the underlying provider — during Next().
Common situations: WMI repository corruption; provider-specific failures (e.g. corrupted performance counters for Win32_PerfFormattedData classes); permission problems on remote namespaces; WMI service throttling.
Related errors
- Got a WMI timeout when infinite wait was specified. This sho
- The query's property enum has no values.
- No results after <timeout> ms.
- Failed to create WbemLocator object.
- Could not set proxy blanket.
AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12).
Data as JSON: /api/errors/855efd887c40fde2.
Report an issue: GitHub.