{"record":{"id":"651a22347d409302","repo":"quarkusio/quarkus","slug":"enclosing-class-not-found-in-index","errorCode":null,"errorMessage":"Enclosing class not found in index: ","messagePattern":"Enclosing class not found in index: ","errorType":"validation","errorClass":"WebSocketServerException","httpStatus":null,"severity":"error","filePath":"extensions/websockets-next/deployment/src/main/java/io/quarkus/websockets/next/deployment/WebSocketProcessor.java","lineNumber":1065,"sourceCode":"        return path.startsWith(\"/\") ? sb.toString() : \"/\" + sb.toString();\n    }\n\n    public static String getOriginalPath(String path) {\n        StringBuilder sb = new StringBuilder();\n        Matcher m = TRANSLATED_PATH_PARAM_PATTERN.matcher(path);\n        while (m.find()) {\n            // Replace :foo with {foo}\n            String match = m.group();\n            m.appendReplacement(sb, \"{\" + match.subSequence(1, match.length()) + \"}\");\n        }\n        m.appendTail(sb);\n        return sb.toString();\n    }\n\n    static String getPathPrefix(IndexView index, DotName enclosingClassName) {\n        ClassInfo enclosingClass = index.getClassByName(enclosingClassName);\n        if (enclosingClass == null) {\n            throw new WebSocketServerException(\"Enclosing class not found in index: \" + enclosingClass);\n        }\n        AnnotationInstance webSocketAnnotation = enclosingClass.annotation(WebSocketDotNames.WEB_SOCKET);\n        if (webSocketAnnotation != null) {\n            String path = getPath(webSocketAnnotation.value(\"path\").asString());\n            if (enclosingClass.nestingType() == NestingType.INNER) {\n                return mergePath(getPathPrefix(index, enclosingClass.enclosingClass()), path);\n            } else {\n                return path.endsWith(\"/\") ? path.substring(path.length() - 1) : path;\n            }\n        }\n        return \"\";\n    }\n\n    private void validateOnPingMessage(Callback callback) {\n        if (KotlinUtils.isKotlinMethod(callback.method)) {\n            if (!callback.isReturnTypeVoid() && !isUniVoid(callback.returnType())\n                    && !callback.isKotlinSuspendFunctionReturningUnit()) {\n                throw new WebSocketServerException(","sourceCodeStart":1047,"sourceCodeEnd":1083,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/websockets-next/deployment/src/main/java/io/quarkus/websockets/next/deployment/WebSocketProcessor.java#L1047-L1083","documentation":"For nested endpoint classes the processor computes the full path prefix by resolving enclosing classes in the Jandex index. If an enclosing class cannot be found in the index, the build fails. Note the message prints the null variable, so the class name is effectively missing from the output — the actual name is the enclosingClassName passed to getPathPrefix.","triggerScenarios":"A @WebSocket endpoint declared as a nested/inner class whose enclosing class is not part of the build-time index (not indexed, excluded from indexing, or synthesized), while the processor walks enclosingClass() chains.","commonSituations":"Nested endpoint classes inside classes that are themselves excluded from the index; build setups removing classes from Jandex indexing; proxies or generated enclosing classes; exotic packaging where the enclosing class lives outside the indexed artifacts.","solutions":["Ensure the enclosing class is a normal, indexed application class (avoid placing endpoints inside generated/proxied/excluded classes).","Prefer top-level endpoint classes to avoid the enclosing-class resolution path entirely.","If nesting is required, keep the whole nesting chain in src/main/java of the indexed module.","Inspect the build index: confirm the enclosing class name appears in the application's Jandex index before filing a bug."],"exampleFix":"// before (enclosing class may be unindexed/generated)\npublic class GeneratedHolder { @WebSocket(path = \"/ws\") public class Nested { } }\n\n// after\n@WebSocket(path = \"/ws\")\npublic class MyEndpoint { }","handlingStrategy":"validation","validationCode":"// Prefer top-level endpoint classes; if nested, verify the enclosing class is a plain indexed class\nstatic void checkEnclosing(Class<?> endpoint) {\n    Class<?> outer = endpoint.getEnclosingClass();\n    if (outer != null && (outer.isSynthetic() || outer.getName().contains(\"$\")))\n        throw new IllegalStateException(\"Enclosing class \" + outer + \" may not be in the Jandex index; use a top-level endpoint\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare @WebSocket endpoints as top-level classes","Avoid generating/proxying classes that contain endpoints","Keep the whole nesting chain in the indexed application module","Check the build index if you must nest endpoint classes"],"tags":["quarkus","websockets-next","jandex","index","build-time"],"backgroundTag":"class-not-in-index","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}