{"record":{"id":"a94d44acad77110e","repo":"apache/druid","slug":"failed-to-instantiate-thrift-class-s","errorCode":null,"errorMessage":"Failed to instantiate Thrift class [%s]","messagePattern":"Failed to instantiate Thrift class \\[(.+?)\\]","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftReader.java","lineNumber":120,"sourceCode":"  {\n    return Collections.singletonList(toFlattenedMap(intermediateRow));\n  }\n\n  private Map<String, Object> toFlattenedMap(byte[] bytes) throws ParseException\n  {\n    try {\n      final Class<TBase> clazz = getThriftClass();\n      final TBase tbase = clazz.newInstance();\n      ThriftDeserialization.detectAndDeserialize(bytes, tbase);\n      final String json = ThriftDeserialization.SERIALIZER_SIMPLE_JSON.get().toString(tbase);\n      final JsonNode node = OBJECT_MAPPER.readTree(json);\n      return recordFlattener.flatten(node);\n    }\n    catch (TException | IOException e) {\n      throw new ParseException(null, e, \"Failed to deserialize Thrift data\");\n    }\n    catch (InstantiationException | IllegalAccessException e) {\n      throw new ParseException(null, e, \"Failed to instantiate Thrift class [%s]\", thriftClassName);\n    }\n    catch (ClassNotFoundException e) {\n      throw new ParseException(null, e, \"Thrift class [%s] not found\", thriftClassName);\n    }\n  }\n\n  @SuppressWarnings({\"unchecked\", \"ReturnValueIgnored\"})\n  private Class<TBase> getThriftClass() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException\n  {\n    if (thriftClass == null) {\n      final Class<TBase> clazz;\n      if (jarPath != null) {\n        File jar = new File(jarPath);\n        URLClassLoader child = new URLClassLoader(\n            new URL[]{jar.toURI().toURL()},\n            this.getClass().getClassLoader()\n        );\n        clazz = (Class<TBase>) Class.forName(thriftClassName, true, child);","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftReader.java#L102-L138","documentation":"toFlattenedMap() calls Class.newInstance() on the configured Thrift class; this catch branch converts InstantiationException/IllegalAccessException into a ParseException. It fires when the configured class cannot be instantiated reflectively — typically an abstract class or interface, or one without an accessible no-argument constructor — not because of bad data.","triggerScenarios":"Thrown at extensions-contrib/thrift-extensions/src/main/java/org/apache/druid/data/input/thrift/ThriftReader.java:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the thriftClassName configured on the ThriftInput matches a class on the task classpath; a wrong or missing class yields a null/failed instantiation from getThriftClass().","Rebuild/redeploy the job with the compiled Thrift-generated TBase classes included in the ingestion spec's classpath or extensions directory.","Check that the thrift protocol and transport settings in the input spec are consistent with the serialized data, since deserialization failures wrapped here can also stem from TException during detectAndDeserialize.","Inspect the wrapped cause (TException/IOException) in the ParseException stack trace to distinguish class-loading problems from malformed record bytes.","Upgrade or align the thrift-extensions version with the thrift library version used to generate the data classes to avoid newInstance() incompatibilities."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}