apache/dubbo · error · NoSuchElementException

'${key}' doesn't map to an existing object

Error message

'${key}' doesn't map to an existing object

What it means

Thrown by Configuration.getInt(key) (no-default overload) when the key is absent or maps to null. Unlike getInt(key, defaultValue), the no-default form has no fallback, so a missing configuration value is a hard error reported as NoSuchElementException.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/config/Configuration.java:63

     * Get a string associated with the given configuration key.
     * If the key doesn't map to an existing object, the default value
     * is returned.
     *
     * @param key          The configuration key.
     * @param defaultValue The default value.
     * @return The associated string if key is found and has valid
     * format, default value otherwise.
     */
    default String getString(String key, String defaultValue) {
        return convert(String.class, key, defaultValue);
    }

    default int getInt(String key) {
        Integer i = this.getInteger(key, null);
        if (i != null) {
            return i;
        } else {
            throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object");
        }
    }

    default int getInt(String key, int defaultValue) {
        Integer i = this.getInteger(key, null);
        return i == null ? defaultValue : i;
    }

    default Integer getInteger(String key, Integer defaultValue) {
        try {
            return convert(Integer.class, key, defaultValue);
        } catch (NumberFormatException e) {
            // 0-2 Property type mismatch.
            interfaceLevelLogger.error(
                    COMMON_PROPERTY_TYPE_MISMATCH,
                    "typo in property value",
                    "This property requires an integer value.",
                    "Actual Class: " + getClass().getName(),

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Use getInt(key, defaultValue) if a default is acceptable.
  2. Set the missing property in dubbo.properties / system property / environment.
  3. Double-check the key spelling and the documented property name.
  4. Verify the Configuration object is wired to the right configuration sources.

Example fix

// before
int port = config.getInt("dubbo.protocol.port");  // throws if unset
// after
int port = config.getInt("dubbo.protocol.port", 20880);  // safe default
Defensive patterns

Strategy: validation

Validate before calling

Integer i = config.getInteger(key, null);
if (i == null) {
    // key missing; use default or fail with a clear message
    i = defaultValue;
}
int value = i;

Type guard

static boolean hasIntConfig(Configuration config, String key) {
    return config.getInteger(key, null) != null;
}

Try / catch

try {
    int v = config.getInt(key);
} catch (java.util.NoSuchElementException e) {
    // key absent; supply default or set required property
}

Prevention

When it happens

Trigger: Calling config.getInt(key) where key is not present in any configuration source (system properties, dubbo.properties, environment, registry config) or its value is empty/null.

Common situations: A required integer configuration property was not set. Typo in the property key. The configuration source (e.g. a properties file or registry) did not load. Environment-specific setup missed a required property.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/571c8b47495e4257. Report an issue: GitHub.