quarkusio/quarkus · error · IllegalArgumentException
Class which is annotated with @RepositoryDefinition cannot…
Error message
Class ${classInfo.name()} which is annotated with @RepositoryDefinition cannot also extend ${supportedRepository} What it means
A class annotated with @RepositoryDefinition (Spring Data's way to define a repository interface without extending CrudRepository) was found to also extend one of Quarkus's supported repository interfaces (CrudRepository, JpaRepository, etc.). This combination is ambiguous and rejected with IllegalArgumentException during augmentation.
Solutions
- Remove @RepositoryDefinition and rely on the extended supported repository interface
- Or remove the 'extends <supportedRepository>' clause and keep only @RepositoryDefinition with its domain type and ID type parameters
- Verify the class is a pure @RepositoryDefinition interface: it should not extend CrudRepository/PagingAndSortingRepository/JpaRepository/ReactiveCrudRepository etc.
Example fix
// before
@RepositoryDefinition(domainClass = User.class, idClass = Long.class)
public interface UserRepository extends CrudRepository<User, Long> {}
// after (choose one style)
@RepositoryDefinition(domainClass = User.class, idClass = Long.class)
public interface UserRepository {}
// or
public interface UserRepository extends CrudRepository<User, Long> {} Defensive patterns
Strategy: validation
Validate before calling
// Fail fast in an architecture test: // assertThat(repoClass.isAnnotationPresent(RepositoryDefinition.class) // && Arrays.stream(repoClass.getInterfaces()).anyMatch(i -> SUPPORTED.contains(i.getName()))).isFalse();
Try / catch
try {
// repository bootstrap at app start
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("@RepositoryDefinition cannot also extend")) {
throw new IllegalStateException("Pick one repository style: " + e.getMessage());
}
throw e;
} Prevention
- Choose one style per repository: either @RepositoryDefinition or extending a supported interface
- Don't add @RepositoryDefinition to interfaces that already extend CrudRepository/JpaRepository
- Run an ArchUnit or build-time check over repository interfaces in CI
When it happens
Trigger: An interface annotated @RepositoryDefinition whose 'extends' clause lists a supported Spring Data repository interface (e.g. extends CrudRepository<T, ID>) — detected in addRepositoryDefinitionInstances while scanning indexed classes.
Common situations: Merging a custom repository definition with an inherited base interface during a refactor; copy-pasting @RepositoryDefinition onto a repository that already extends JpaRepository; SDK-generated repositories adding the annotation.
Related errors
- Cannot use Let's Encrypt without the quarkus-vertx-http…
- Clustered jobs configured with unsupported job store option
- Configuration property…
- Could not retrieve from credentials provider
- Distinct is not yet supported. Offending method is
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/0b70c1767f886233.
Report an issue: GitHub.
Appendix: source
Thrown at extensions/spring-data-jpa/deployment/src/main/java/io/quarkus/spring/data/deployment/SpringDataJPAProcessor.java:174
noRepositoryBeanRepos.removeIf(DotNames.SUPPORTED_REPOSITORIES::contains);
Set<ClassInfo> interfacesExtending = getAllInterfacesExtending(noRepositoryBeanRepos, indexView);
interfacesExtendingRepository.addAll(interfacesExtending);
}
// classes annotated with @RepositoryDefinition behave exactly as if they extended Repository
private void addRepositoryDefinitionInstances(IndexView indexView, Set<ClassInfo> interfacesExtendingRepository) {
Collection<AnnotationInstance> repositoryDefinitions = indexView
.getAnnotations(DotNames.SPRING_DATA_REPOSITORY_DEFINITION);
for (AnnotationInstance repositoryDefinition : repositoryDefinitions) {
AnnotationTarget target = repositoryDefinition.target();
if (target.kind() != AnnotationTarget.Kind.CLASS) {
continue;
}
ClassInfo classInfo = target.asClass();
Set<DotName> supportedRepositories = DotNames.SUPPORTED_REPOSITORIES;
for (DotName supportedRepository : supportedRepositories) {
if (classInfo.interfaceNames().contains(supportedRepository)) {
throw new IllegalArgumentException("Class " + classInfo.name()
+ " which is annotated with @RepositoryDefinition cannot also extend " + supportedRepository);
}
}
interfacesExtendingRepository.add(classInfo);
}
}
private void detectAndLogSpecificSpringPropertiesIfExist() {
Config config = ConfigProvider.getConfig();
Iterable<String> iterablePropertyNames = config.getPropertyNames();
List<String> propertyNames = new ArrayList<String>();
iterablePropertyNames.forEach(propertyNames::add);
List<String> springProperties = propertyNames.stream().filter(s -> pattern.matcher(s).matches()).toList();
String notSupportedProperties = "";
if (!springProperties.isEmpty()) {
for (String sp : springProperties) {View on GitHub (pinned to e1c734241f)