quarkusio/quarkus · error · RuntimeException

should not be extended or implemented

Error message

 should not be extended or implemented

What it means

REST Data Panache resource interfaces must be leaves: nothing may extend or implement them. If the Jandex index shows known direct implementors of the resource interface, validateResource throws RuntimeException '<class> should not be extended or implemented'.

Source

Thrown at extensions/panache/mongodb-rest-data-panache/deployment/src/main/java/io/quarkus/mongodb/rest/data/panache/deployment/MongoPanacheRestProcessor.java:146

                            getEntityFields(index.getIndex(), entityType))));
            if (capabilities.isPresent(Capability.RESTEASY)) {
                bytecodeTransformersProducer.produce(
                        getEntityIdAnnotationTransformer(entityType, entityClassHelper.getIdField(entityType).name()));
            }
        }
    }

    private void validateResource(IndexView index, ClassInfo classInfo) {
        if (!Modifier.isInterface(classInfo.flags())) {
            throw new RuntimeException(classInfo.name() + " has to be an interface");
        }

        if (classInfo.interfaceNames().size() > 1) {
            throw new RuntimeException(classInfo.name() + " should only extend REST Data Panache interface");
        }

        if (!index.getKnownDirectImplementors(classInfo.name()).isEmpty()) {
            throw new RuntimeException(classInfo.name() + " should not be extended or implemented");
        }
    }

    private List<Type> getGenericTypes(ClassInfo classInfo) {
        return classInfo.interfaceTypes()
                .stream()
                .findFirst()
                .orElseThrow(() -> new RuntimeException(classInfo.toString() + " does not have generic types"))
                .asParameterizedType()
                .arguments();
    }

    /**
     * Annotate Mongo entity ID fields with a RESTEasy links annotation.
     * Otherwise, RESTEasy will not be able to generate links that use ID as path parameter.
     */
    private BytecodeTransformerBuildItem getEntityIdAnnotationTransformer(String entityClassName, String idFieldName) {
        return new BytecodeTransformerBuildItem(entityClassName,

View on GitHub (pinned to e1c734241f)

Solutions

  1. Delete the class extending/implementing the resource interface; customization is done by adding methods to the interface itself (with default implementations calling the repository).
  2. Move custom logic into the repository bean instead of implementing the resource.
  3. Exclude the implementing class from bean discovery/indexing if it is not meant to be a resource.

Example fix

// before
public class CustomBookResource implements BookResource { ... } // not allowed
// after
public interface BookResource extends PanacheMongoRepositoryResource<Book, ObjectId> {
    default List<Book> findByTitle(String title) {
        return list("title", title); // customize via interface methods
    }
}
Defensive patterns

Strategy: validation

Validate before calling

// ensure no class implements the resource
Set<Class<?>> impls = indexScanner.findImplementors(resource);
if (!impls.isEmpty()) throw new IllegalArgumentException("Resource interfaces must not be implemented: " + impls);

Prevention

When it happens

Trigger: Creating a class that implements the resource interface, or a sub-interface extending it, in application code discovered by the build-time index.

Common situations: Trying to provide a custom implementation of the generated resource; extending a resource interface to add endpoints; accidentally implementing it in a test/CDI bean that gets indexed.

Related errors


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