{"record":{"id":"97aa022600f37ed1","repo":"quarkusio/quarkus","slug":"non-static-nested-resources-classes-are-not-suppor","errorCode":null,"errorMessage":"Non static nested resources classes are not supported: '","messagePattern":"Non static nested resources classes are not supported: '","errorType":"validation","errorClass":"DeploymentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java","lineNumber":277,"sourceCode":"        this.parameterContainerTypes = builder.parameterContainerTypes;\n        this.multipartReturnTypeIndexerExtension = builder.multipartReturnTypeIndexerExtension;\n        this.targetJavaVersion = builder.targetJavaVersion;\n        this.isDisabledCreator = builder.isDisabledCreator;\n        this.skipMethodParameter = builder.skipMethodParameter;\n        this.skipNotRestParameters = builder.skipNotRestParameters;\n        this.validateEndpoint = builder.defaultPredicate;\n        this.alreadyHandledRequestScopedResources = builder.alreadyHandledRequestScopedResources;\n    }\n\n    public Optional<ResourceClass> createEndpoints(ClassInfo classInfo, boolean considerApplication) {\n        if (considerApplication && !applicationScanningResult.keepClass(classInfo.name().toString())) {\n            return Optional.empty();\n        }\n        try {\n            String path = scannedResourcePaths.get(classInfo.name());\n            ResourceClass clazz = new ResourceClass();\n            if ((classInfo.enclosingClass() != null) && !Modifier.isStatic(classInfo.flags())) {\n                throw new DeploymentException(\n                        \"Non static nested resources classes are not supported: '\" + classInfo.name() + \"'\");\n            }\n            clazz.setClassName(classInfo.name().toString());\n            if (path != null) {\n                if (path.endsWith(\"/\")) {\n                    path = handleTrailingSlash(path);\n                }\n                if (!path.startsWith(\"/\")) {\n                    path = \"/\" + path;\n                }\n                clazz.setPath(sanitizePath(path));\n            }\n            if (factoryCreator != null && !classInfo.isInterface() && !classInfo.isAbstract()) {\n                // Most likely an interface or an abstract class in the hierarchy of a sub resource.\n                // The ResourceLocatorHandler does not use the factory to create new instances, but uses the result of the sub resource locator method instead\n                // Interfaces therefore do not need a factory here\n                // Otherwise, when having multiple implementations of the interface or abstract class, an Ambiguous Bean Resolution error occurs,\n                // since io.quarkus.arc.runtime.BeanContainerImpl.createFactory is run, even if the factory is never invoked","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java#L259-L295","documentation":"EndpointIndexer.createEndpoints indexes JAX-RS resource classes during the Quarkus build. A non-static nested (inner) class annotated as a resource cannot be instantiated or proxied properly, so a DeploymentException 'Non static nested resources classes are not supported' is thrown. Static nested classes and top-level classes are fine.","triggerScenarios":"A class annotated with @Path is declared as a non-static inner class of another class, and createEndpoints processes it during augmentation.","commonSituations":"Declaring a small REST resource as an inner class inside a test or main class and forgetting the `static` modifier; refactor moving a resource class inside another class without keeping staticness.","solutions":["Add the `static` modifier to the nested resource class","Move the resource class to a top-level file","Remove the @Path annotation if the class is not meant to be a resource"],"exampleFix":"// before\nclass MyResourceHolder {\n    @Path(\"/hello\")\n    class HelloResource { @GET String get() { return \"hi\"; } }\n}\n// after\nclass MyResourceHolder {\n    @Path(\"/hello\")\n    static class HelloResource { @GET String get() { return \"hi\"; } }\n}","handlingStrategy":"validation","validationCode":"// preflight: resource classes must be top-level or static\nstatic void checkResource(Class<?> clazz) {\n    if (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers()))\n        throw new IllegalArgumentException(clazz + \" must be static or top-level\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare nested @Path classes as static","Keep resource classes in their own top-level files","Add checkstyle/ArchUnit rules forbidding non-static inner @Path classes"],"tags":["jaxrs","deployment","build-time","quarkus"],"backgroundTag":"non-static-nested-resource","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"}