quarkusio/quarkus · error · DeploymentException

Non static nested resources classes are not supported: '

Error message

Non static nested resources classes are not supported: '

What it means

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.

Source

Thrown at independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java:277

        this.parameterContainerTypes = builder.parameterContainerTypes;
        this.multipartReturnTypeIndexerExtension = builder.multipartReturnTypeIndexerExtension;
        this.targetJavaVersion = builder.targetJavaVersion;
        this.isDisabledCreator = builder.isDisabledCreator;
        this.skipMethodParameter = builder.skipMethodParameter;
        this.skipNotRestParameters = builder.skipNotRestParameters;
        this.validateEndpoint = builder.defaultPredicate;
        this.alreadyHandledRequestScopedResources = builder.alreadyHandledRequestScopedResources;
    }

    public Optional<ResourceClass> createEndpoints(ClassInfo classInfo, boolean considerApplication) {
        if (considerApplication && !applicationScanningResult.keepClass(classInfo.name().toString())) {
            return Optional.empty();
        }
        try {
            String path = scannedResourcePaths.get(classInfo.name());
            ResourceClass clazz = new ResourceClass();
            if ((classInfo.enclosingClass() != null) && !Modifier.isStatic(classInfo.flags())) {
                throw new DeploymentException(
                        "Non static nested resources classes are not supported: '" + classInfo.name() + "'");
            }
            clazz.setClassName(classInfo.name().toString());
            if (path != null) {
                if (path.endsWith("/")) {
                    path = handleTrailingSlash(path);
                }
                if (!path.startsWith("/")) {
                    path = "/" + path;
                }
                clazz.setPath(sanitizePath(path));
            }
            if (factoryCreator != null && !classInfo.isInterface() && !classInfo.isAbstract()) {
                // Most likely an interface or an abstract class in the hierarchy of a sub resource.
                // The ResourceLocatorHandler does not use the factory to create new instances, but uses the result of the sub resource locator method instead
                // Interfaces therefore do not need a factory here
                // Otherwise, when having multiple implementations of the interface or abstract class, an Ambiguous Bean Resolution error occurs,
                // since io.quarkus.arc.runtime.BeanContainerImpl.createFactory is run, even if the factory is never invoked

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add the `static` modifier to the nested resource class
  2. Move the resource class to a top-level file
  3. Remove the @Path annotation if the class is not meant to be a resource

Example fix

// before
class MyResourceHolder {
    @Path("/hello")
    class HelloResource { @GET String get() { return "hi"; } }
}
// after
class MyResourceHolder {
    @Path("/hello")
    static class HelloResource { @GET String get() { return "hi"; } }
}
Defensive patterns

Strategy: validation

Validate before calling

// preflight: resource classes must be top-level or static
static void checkResource(Class<?> clazz) {
    if (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers()))
        throw new IllegalArgumentException(clazz + " must be static or top-level");
}

Prevention

When it happens

Trigger: A class annotated with @Path is declared as a non-static inner class of another class, and createEndpoints processes it during augmentation.

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/97aa022600f37ed1. Report an issue: GitHub.