{"record":{"id":"efffc0ca14eef74b","repo":"quarkusio/quarkus","slug":"resource-is-null","errorCode":null,"errorMessage":"resource is null","messagePattern":"resource is null","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":415,"sourceCode":"    }\n\n    @SuppressWarnings(\"unchecked\")\n    public UriBuilder path(Class resource) throws IllegalArgumentException {\n        if (resource == null)\n            throw new IllegalArgumentException(\"path is null\");\n        Path ann = (Path) resource.getAnnotation(Path.class);\n        if (ann != null) {\n            String[] segments = new String[] { ann.value() };\n            path = paths(true, path, segments);\n        } else {\n            throw new IllegalArgumentException(\"class must be annotated with @Path\");\n        }\n        return this;\n    }\n\n    public UriBuilder path(Class resource, String method) throws IllegalArgumentException {\n        if (resource == null)\n            throw new IllegalArgumentException(\"resource is null\");\n        if (method == null)\n            throw new IllegalArgumentException(\"method is null\");\n        Method theMethod = null;\n        for (Method m : resource.getMethods()) {\n            if (m.getName().equals(method)) {\n                if (theMethod != null && m.isAnnotationPresent(Path.class)) {\n                    throw new IllegalArgumentException(\"Two methods with the same path \" + method);\n                }\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 {","sourceCodeStart":397,"sourceCodeEnd":433,"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#L397-L433","documentation":"UriBuilderImpl.path(Class, String) validates its arguments up front and throws this IllegalArgumentException when the resource Class parameter is null. Without a class there is nothing to reflect over to find the @Path-annotated method, so the builder fails fast.","triggerScenarios":"Invoking path(null, \"methodName\"), typically when the class is obtained from a variable, map lookup, or config value that resolved to null.","commonSituations":"Class.forName with a misspelled class name caught and swallowed, leaving a null Class; reflection-based client generation where the resource type is missing from a registry; conditional code paths that skip class assignment.","solutions":["Ensure the Class variable is non-null before calling path(resource, method).","Fix the class loading/lookup that produced null (verify class name, classpath, dependency).","Guard with Objects.requireNonNull(resource) or an explicit check before the call.","If you already hold a Method object, call path(Method) instead and skip the class lookup."],"exampleFix":"// before\nbuilder.path(resourceClass, \"get\"); // resourceClass may be null\n// after\nObjects.requireNonNull(resourceClass, \"resource class must be provided\");\nbuilder.path(resourceClass, \"get\");","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(resourceClass, \"resource class must not be null\");\nObjects.requireNonNull(methodName, \"method name must not be null\");","typeGuard":"static boolean readyForPath(Class<?> c, String m) {\n    return c != null && m != null;\n}","tryCatchPattern":"try {\n    builder.path(resourceClass, methodName);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"resource is null\")) {\n        throw new IllegalStateException(\"Resource class not resolved for \" + methodName, e);\n    }\n    throw e;\n}","preventionTips":["Never swallow ClassNotFoundException from Class.forName","Null-check class references loaded from config/registries","Prefer passing Method objects over (class, name) pairs","Fail fast at config-load time if a resource class cannot be found"],"tags":["jaxrs","resteasy-reactive","uribuilder","null-check"],"backgroundTag":"null-argument","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"}