{"record":{"id":"da06e12480c890e8","repo":"quarkusio/quarkus","slug":"method-not-annotated-with-path","errorCode":null,"errorMessage":"Method not annotated with @Path","messagePattern":"Method not annotated with @Path","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java","lineNumber":441,"sourceCode":"                }\n                if (m.isAnnotationPresent(Path.class))\n                    theMethod = m;\n            }\n        }\n        if (theMethod == null)\n            throw new IllegalArgumentException(\"No public method annotated with @Path \" + resource.getName() + \" \" + method);\n        return path(theMethod);\n    }\n\n    public UriBuilder path(Method method) throws IllegalArgumentException {\n        if (method == null) {\n            throw new IllegalArgumentException(\"method is null\");\n        }\n        Path ann = method.getAnnotation(Path.class);\n        if (ann != null) {\n            path = paths(encode, path, ann.value());\n        } else {\n            throw new IllegalArgumentException(\"Method not annotated with @Path\");\n        }\n        return this;\n    }\n\n    public UriBuilder replaceMatrix(String matrix) throws IllegalArgumentException {\n        if (matrix == null)\n            matrix = \"\";\n        if (!matrix.startsWith(\";\"))\n            matrix = \";\" + matrix;\n        matrix = Encode.encodePath(matrix);\n        if (path == null) {\n            path = matrix;\n        } else {\n            int start = path.lastIndexOf('/');\n            if (start < 0)\n                start = 0;\n            int matrixIndex = path.indexOf(';', start);\n            if (matrixIndex > -1)","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java#L423-L459","documentation":"UriBuilderImpl.path(Method) builds the segment from the method's @Path annotation value; if the reflective Method has no @Path annotation the builder cannot derive a path and throws this IllegalArgumentException. Note the null-Method case has its own distinct message ('method is null'), so this one means a real Method was supplied but is not an annotated endpoint.","triggerScenarios":"Passing a Method that is a plain helper, getter, or lifecycle method (no @Path) — e.g. from path(Resource.class, \"helperName\") resolution or a random reflective method.","commonSituations":"Mistakenly treating non-endpoint methods as endpoints in client/link generation; the @Path annotation moved to the class only, leaving methods unannotated; annotation processing or Lombok-related setups where the annotation is not visible on the resolved Method.","solutions":["Only pass methods annotated with @Path to path(Method).","Add @Path to the method if it is genuinely an endpoint.","Use path(Class) for the class-level segment and skip methods without @Path.","Pre-check method.isAnnotationPresent(Path.class) before calling."],"exampleFix":"// before\nMethod m = OrderResource.class.getMethod(\"toString\");\nbuilder.path(m); // throws\n// after\nMethod m = OrderResource.class.getMethod(\"get\"); // has @Path\nbuilder.path(m);","handlingStrategy":"validation","validationCode":"if (method != null && !method.isAnnotationPresent(jakarta.ws.rs.Path.class)) {\n    throw new IllegalArgumentException(method + \" is not a @Path-annotated endpoint\");\n}","typeGuard":"static boolean isPathAnnotated(Method m) {\n    return m != null && m.isAnnotationPresent(jakarta.ws.rs.Path.class);\n}","tryCatchPattern":"try {\n    builder.path(method);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Method not annotated with @Path\")) {\n        throw new IllegalStateException(\"Non-endpoint method passed to path(): \" + method, e);\n    }\n    throw e;\n}","preventionTips":["Filter candidate methods by isAnnotationPresent(Path.class) before calling","Do not pass helpers/getters to path(Method)","Remember class-level-only @Path resources still need method-level @Path for path(Method)","Add annotation-presence unit tests for client method discovery"],"tags":["jaxrs","resteasy-reactive","uribuilder","missing-path-annotation"],"backgroundTag":"missing-path-annotation","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}