{"record":{"id":"bd23820e9624eddd","repo":"xai-org/x-algorithm","slug":"cannot-find-class-s-bd2382","errorCode":null,"errorMessage":"cannot find class %s","messagePattern":"cannot find class (.+?)","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/types/TypeCompiler.java","lineNumber":99,"sourceCode":"    }\n    ImmutableList.Builder<Type> paramTypesBuilder = ImmutableList.builder();\n    for (int i = 1; i < tree.getChildCount(); i++) {\n      paramTypesBuilder.add(getType(tree.getChild(i), context));\n    }\n    return Type.of(info.getFirst(), paramTypesBuilder.build());\n  }\n\n  public static Optional<Type> getPrimitiveType(String name) {\n    return Type.getPrimitiveTypeFromName(name);\n  }\n\n  public static Type getTypeFromClassName(String className) throws SemanticCheckFailure {\n\n    Class<?> clazz;\n    try {\n      clazz = ClassCache.forName(className);\n    } catch (Exception e) {\n      throw new SemanticCheckFailure(\n          String.format(\"cannot find class %s\", className)\n      );\n    }\n\n    if (TBase.class.isAssignableFrom(clazz)) {\n      return Type.thriftOf((Class<? extends TBase>) clazz);\n    } else if (ThriftStruct.class.isAssignableFrom(clazz)) {\n      return Type.thriftStructOf((Class<? extends ThriftStruct>) clazz);\n    } else {\n      throw new SemanticCheckFailure(\n          String.format(\"class has to be either a TBase or ThriftStruct: %s.\", className)\n      );\n    }\n  }\n}\n","sourceCodeStart":81,"sourceCodeEnd":115,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/types/TypeCompiler.java#L81-L115","documentation":"TypeCompiler.getTypeFromClassName loads a class by name through ClassCache to build a thrift Type. Any loading failure (ClassNotFoundException and friends) is wrapped as SemanticCheckFailure 'cannot find class %s'.","triggerScenarios":"Referring to a fully-qualified thrift struct class in a rule/binding when the class is absent from the classpath — wrong package, typo in FQN, missing jar, or classloader isolation.","commonSituations":"Deploying rules without the thrift jar containing the struct; renaming the thrift package in the IDL; shading/relocation changing package names; separate classloader environments (app servers) where ClassCache can't see the class.","solutions":["Verify the fully-qualified name matches the generated class exactly","Add the thrift-generated jar containing the class to the botmaker classpath","Check shading/relocation rules and classloader parentage","Rebuild rules against the current schema's package names"],"exampleFix":"// before\nType t = TypeCompiler.getTypeFromClassName(\"com.acme.oldpkg.User\");\n// after\nType t = TypeCompiler.getTypeFromClassName(\"com.acme.newpkg.User\");","handlingStrategy":"validation","validationCode":"try { ClassCache.forName(className); } catch (Exception e) {\n  throw new IllegalArgumentException(\"class not on classpath: \" + className);\n}","typeGuard":null,"tryCatchPattern":"catch SemanticCheckFailure 'cannot find class' and surface as deployment/classpath issue with the FQN","preventionTips":["Ship thrift jars with the rules that reference them","Startup smoke-test loading every referenced class"],"tags":["classpath","class-not-found","thrift"],"backgroundTag":"class-not-found-on-classpath","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}