json-path/JsonPath · warning · UnsupportedOperationException

JSON-P adapter does not support getLocation()

Error message

JSON-P adapter does not support getLocation()

What it means

The JSON-P parser adapter inside JakartaMappingProvider does not implement getLocation(); calling it always throws UnsupportedOperationException. JSON-P's streaming API surface in this adapter does not carry location info, so the method is deliberately unimplemented.

Source

Thrown at json-path/src/main/java/com/jayway/jsonpath/spi/mapper/JakartaMappingProvider.java:511

        @Override
        public long getLong() {
            if (state == Event.VALUE_NUMBER) {
                return ((JsonNumber) scope.getValue()).longValue();
            }
            throw new IllegalStateException("Target json value must a number, not " + state);
        }

        @Override
        public BigDecimal getBigDecimal() {
            if (state == Event.VALUE_NUMBER) {
                return ((JsonNumber) scope.getValue()).bigDecimalValue();
            }
            throw new IllegalStateException("Target json value must a number, not " + state);
        }

        @Override
        public JsonLocation getLocation() {
            throw new UnsupportedOperationException("JSON-P adapter does not support getLocation()");
        }

        @Override
        public void skipArray() {
            if (scope instanceof JsonArrayScope) {
                while (scope.hasNext()) {
                    scope.next();
                }
                state = Event.END_ARRAY;
            }
        }

        @Override
        public void skipObject() {
            if (scope instanceof JsonObjectScope) {
                while (scope.hasNext()) {
                    scope.next();
                }

View on GitHub (pinned to 62a4c9f0f6)

Solutions

  1. Do not call getLocation() when using the JakartaMappingProvider; guard with a capability check or catch UnsupportedOperationException
  2. Log position via your own token counter instead of parser locations
  3. Switch to a mapping provider that supports parser locations if coordinates are required

Example fix

// before
JsonLocation loc = parser.getLocation(); // always throws
// after
try {
    JsonLocation loc = parser.getLocation();
} catch (UnsupportedOperationException e) {
    // JSON-P adapter: no location info; track line/offset yourself
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    JsonLocation loc = parser.getLocation();
} catch (UnsupportedOperationException e) {
    // JSON-P adapter provides no location; track offsets manually
}

Prevention

When it happens

Trigger: Calling getLocation() on the JsonParser adapter created by JakartaMappingProvider (e.g. code that logs error positions from parsers, or generic parser-handling utilities).

Common situations: Debugging/telemetry code that reports JSON parse coordinates; switching from another JsonProvider (like Jackson) that supports locations to the Jakarta/JSON-P provider.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of json-path/JsonPath@62a4c9f0f6 (2026-09-11). Data as JSON: /api/errors/d47e6f98f8ad4568. Report an issue: GitHub.