json-path/JsonPath · error · UnsupportedOperationException

Tapestry JSON provider does not support TypeRef! Use a Jacks

Error message

Tapestry JSON provider does not support TypeRef! Use a Jackson or Gson based provider

What it means

TapestryMappingProvider.map(Object, TypeRef<T>, Configuration) is deliberately unimplemented: it always throws UnsupportedOperationException with this message. TypeRef (generic super-type-token) mapping is not supported by the Tapestry provider, so any generic type request fails unconditionally, regardless of the source value.

Source

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

      if (targetType.isAssignableFrom(ArrayList.class) && configuration.jsonProvider().isArray(source)) {
        int length = configuration.jsonProvider().length(source);
        @SuppressWarnings("rawtypes")
        ArrayList list = new ArrayList(length);
        for (Object o : configuration.jsonProvider().toIterable(source)) {
          list.add(o);
        }
        return (T) list;
      }
    } catch (Exception e) {

    }
    throw new MappingException("Cannot convert a " + source.getClass().getName() + " to a " + targetType
        + " use Tapestry's TypeCoercer instead.");
  }

  @Override
  public <T> T map(final Object source, final TypeRef<T> targetType, final Configuration configuration) {
    throw new UnsupportedOperationException(
        "Tapestry JSON provider does not support TypeRef! Use a Jackson or Gson based provider");
  }

}

View on GitHub (pinned to 62a4c9f0f6)

Solutions

  1. Switch the mapping provider: Configuration.setMappingProvider(new JacksonMappingProvider()) or GsonMappingProvider — both support TypeRef.
  2. If Tapestry must stay, map to the raw Class type (List.class/Map.class) and convert elements manually.
  3. Use JsonPath.parse(...).read(path) to get a plain Object/JSONArray and transform it yourself.
  4. Ensure a single provider is used consistently; avoid Tapestry for generic-type mapping.

Example fix

// before
Configuration conf = Configuration.defaultConfiguration(); // Tapestry/default path
List<Foo> list = JsonPath.read(json, "$[*]", new TypeRef<List<Foo>>(){}, conf); // UnsupportedOperationException
// after
Configuration conf = Configuration.defaultConfiguration()
    .setMappingProvider(new JacksonMappingProvider());
List<Foo> list = JsonPath.read(json, "$[*]");
Defensive patterns

Strategy: fallback

Validate before calling

MappingProvider mp = configuration.mappingProvider();
if (mp instanceof TapestryMappingProvider && usesTypeRef)
    throw new IllegalStateException("Configure JacksonMappingProvider/GsonMappingProvider for TypeRef support");

Try / catch

try {
    List<Foo> list = JsonPath.parse(json).read("$[*]", new TypeRef<List<Foo>>(){}, configuration);
} catch (UnsupportedOperationException e) {
    Configuration jacksonCfg = configuration.setMappingProvider(new JacksonMappingProvider());
    List<Foo> list = JsonPath.parse(json).read("$[*]", new TypeRef<List<Foo>>(){}, jacksonCfg);
}

Prevention

When it happens

Trigger: Any call to map(source, new TypeRef<List<MyType>>(){}, configuration) — or JsonPath reads with .map(new TypeRef<T>(){}) — while TapestryMappingProvider is the configured mapping provider.

Common situations: Reading JSON arrays into typed Lists (JsonPath.parse(...).read("$[*]", new TypeRef<List<Foo>>(){})) with the Tapestry provider; copying configuration/code from a Jackson- or Gson-based setup without changing the 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/b6680aa29fd2589b. Report an issue: GitHub.