{"record":{"id":"b6680aa29fd2589b","repo":"json-path/JsonPath","slug":"tapestry-json-provider-does-not-support-typeref-u","errorCode":null,"errorMessage":"Tapestry JSON provider does not support TypeRef! Use a Jackson or Gson based provider","messagePattern":"Tapestry JSON provider does not support TypeRef! Use a Jackson or Gson based provider","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/spi/mapper/TapestryMappingProvider.java","lineNumber":51,"sourceCode":"      if (targetType.isAssignableFrom(ArrayList.class) && configuration.jsonProvider().isArray(source)) {\n        int length = configuration.jsonProvider().length(source);\n        @SuppressWarnings(\"rawtypes\")\n        ArrayList list = new ArrayList(length);\n        for (Object o : configuration.jsonProvider().toIterable(source)) {\n          list.add(o);\n        }\n        return (T) list;\n      }\n    } catch (Exception e) {\n\n    }\n    throw new MappingException(\"Cannot convert a \" + source.getClass().getName() + \" to a \" + targetType\n        + \" use Tapestry's TypeCoercer instead.\");\n  }\n\n  @Override\n  public <T> T map(final Object source, final TypeRef<T> targetType, final Configuration configuration) {\n    throw new UnsupportedOperationException(\n        \"Tapestry JSON provider does not support TypeRef! Use a Jackson or Gson based provider\");\n  }\n\n}\n","sourceCodeStart":33,"sourceCodeEnd":56,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/spi/mapper/TapestryMappingProvider.java#L33-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Switch the mapping provider: Configuration.setMappingProvider(new JacksonMappingProvider()) or GsonMappingProvider — both support TypeRef.","If Tapestry must stay, map to the raw Class type (List.class/Map.class) and convert elements manually.","Use JsonPath.parse(...).read(path) to get a plain Object/JSONArray and transform it yourself.","Ensure a single provider is used consistently; avoid Tapestry for generic-type mapping."],"exampleFix":"// before\nConfiguration conf = Configuration.defaultConfiguration(); // Tapestry/default path\nList<Foo> list = JsonPath.read(json, \"$[*]\", new TypeRef<List<Foo>>(){}, conf); // UnsupportedOperationException\n// after\nConfiguration conf = Configuration.defaultConfiguration()\n    .setMappingProvider(new JacksonMappingProvider());\nList<Foo> list = JsonPath.read(json, \"$[*]\");","handlingStrategy":"fallback","validationCode":"MappingProvider mp = configuration.mappingProvider();\nif (mp instanceof TapestryMappingProvider && usesTypeRef)\n    throw new IllegalStateException(\"Configure JacksonMappingProvider/GsonMappingProvider for TypeRef support\");","typeGuard":null,"tryCatchPattern":"try {\n    List<Foo> list = JsonPath.parse(json).read(\"$[*]\", new TypeRef<List<Foo>>(){}, configuration);\n} catch (UnsupportedOperationException e) {\n    Configuration jacksonCfg = configuration.setMappingProvider(new JacksonMappingProvider());\n    List<Foo> list = JsonPath.parse(json).read(\"$[*]\", new TypeRef<List<Foo>>(){}, jacksonCfg);\n}","preventionTips":["Never pair TypeRef-based reads with TapestryMappingProvider; it is unimplemented by design.","Default to JacksonMappingProvider or GsonMappingProvider when you need generic type tokens.","Centralize Configuration setup so the provider choice is explicit and audited in one place.","When stuck on Tapestry, map to raw Class targets (Map/List) and convert elements manually."],"tags":["json-path","mapping","tapestry","unsupported-operation","typeref"],"backgroundTag":"unsupported-operation","analyzedSha":"62a4c9f0f65ba3f625aa0867d64c528ba72d09ec","analyzedAt":"2026-09-11T11:36:00.448Z","contentChangedAt":"2026-09-11T11:36:00.448Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}