quarkusio/quarkus · error · RuntimeException

should only extend REST Data Panache interface

Error message

 should only extend REST Data Panache interface

What it means

validateResource additionally requires that the resource interface extends exactly one REST Data Panache interface. An interface with more than one direct interface name triggers RuntimeException '<class> should only extend REST Data Panache interface'.

Source

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

                    new UnremovableBeanBuildItem.BeanClassNameExclusion(repositoryClassName)));

            restDataResourceProducer.produce(new RestDataResourceBuildItem(
                    new ResourceMetadata(resourceClass, resourceInterface, entityType, idType,
                            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.

View on GitHub (pinned to e1c734241f)

Solutions

  1. Reduce the resource to extend exactly one REST Data Panache interface.
  2. Move shared custom endpoint logic into a separate CDI bean/service the generated resource can call, not extra super-interfaces.
  3. Remove the extra marker interface.

Example fix

// before
public interface BookResource extends PanacheMongoRepositoryResource<Book, ObjectId>, CustomResource {}
// after
public interface BookResource extends PanacheMongoRepositoryResource<Book, ObjectId> {}
Defensive patterns

Strategy: validation

Validate before calling

if (Arrays.stream(resource.getInterfaces()).count() > 1) throw new IllegalArgumentException("Resource must extend exactly one REST Data Panache interface");

Prevention

When it happens

Trigger: Declaring a REST data resource interface that extends two or more interfaces (e.g. a Panache resource interface plus a custom mixin or another resource interface).

Common situations: Trying to compose several resource interfaces to reuse custom endpoints; adding a marker interface to the resource; refactoring that merged two resource types.

Related errors


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