quarkusio/quarkus · error · RuntimeException
The role element type must be indexed by Jandex: ${elementTy
Error message
The role element type must be indexed by Jandex: ${elementType} What it means
When the @Roles field/getter is a List/Collection/Set of a non-String element type, the role entity class must be present in the Jandex application index so the build-time generator can inspect its @RoleValue member. If index.getClassByName returns null the build fails.
Source
Thrown at extensions/security-jpa-common/deployment/src/main/java/io/quarkus/security/jpa/common/deployment/JpaSecurityIdentityUtil.java:171
// JpaIdentityProviderUtil.addRoles(builder, :role)
bc.invokeStatic(
MethodDesc.of(JpaIdentityProviderUtil.class, "addRoles", void.class,
QuarkusSecurityIdentity.Builder.class, String.class),
builderVar, role);
handledRole = true;
}
break;
case PARAMETERIZED_TYPE:
DotName roleType = rolesType.name();
if (roleType.equals(DotNames.LIST)
|| roleType.equals(DOTNAME_COLLECTION)
|| roleType.equals(DOTNAME_SET)) {
Type elementType = rolesType.asParameterizedType().arguments().get(0);
JpaSecurityDefinition.FieldOrMethod rolesFieldOrMethod;
if (!elementType.name().equals(DotNames.STRING)) {
ClassInfo roleClass = index.getClassByName(elementType.name());
if (roleClass == null) {
throw new RuntimeException(
"The role element type must be indexed by Jandex: " + elementType);
}
AnnotationTarget annotatedRolesValue = getSingleAnnotatedElement(index, DOTNAME_ROLES_VALUE);
rolesFieldOrMethod = JpaSecurityDefinition.getFieldOrMethod(index, roleClass,
annotatedRolesValue, panacheEntityPredicate.isPanache(roleClass));
if (rolesFieldOrMethod == null) {
throw new RuntimeException(
"Missing @RoleValue annotation on (non-String) role element type: " + elementType);
}
} else {
rolesFieldOrMethod = null;
}
// for(:elementType roleElement : :role){
// JpaIdentityProviderUtil.addRoles(:role.roleField);
// // or for String collections:
// JpaIdentityProviderUtil.addRoles(:role);
// }
bc.forEach(role, (loopBody, var) -> {View on GitHub (pinned to e1c734241f)
Solutions
- Ensure the role entity class is in your application source so Quarkus indexes it.
- For classes in a dependency JAR, add a Jandex index: configure jandex-maven-plugin in that project, or add quarkus.index-dependency.* properties (quarkus.index-dependency.<name>.group-id/artifact-id) in application.properties.
- Alternatively, store roles as List<String>/Set<String> so no role class indexing is needed.
Example fix
// application.properties, role entity lives in an unindexed dependency // before # (role class not indexed) // after quarkus.index-dependency.my-roles.group-id=com.example quarkus.index-dependency.my-roles.artifact-id=role-entities
Defensive patterns
Strategy: validation
Validate before calling
if (index.getClassByName(DotName.createSimple("com.example.Role")) == null) {
throw new IllegalStateException("Role class not in Jandex index; add quarkus.index-dependency.*");
} Prevention
- Keep role entities in the application module or in an indexed dependency.
- Configure quarkus.index-dependency.<name>.group-id/artifact-id for external JARs.
- Prefer List<String>/Set<String> roles when no entity is needed.
When it happens
Trigger: Declaring @Roles on a field of type List<MyRole> (or Set/Collection) where MyRole is not indexed by Jandex — e.g. the class comes from a binary dependency that is not indexed, is generated, or Quarkus cannot index the containing artifact.
Common situations: Role entity defined in a separate library JAR without a Jandex index (missing jandex-maven-plugin or META-INF/jandex.idx); role class generated at build time; using JDK/internal types as the element type.
Related errors
- You can only annotate one field or method with @${annotation
- Invalid type:
- Injected class not found in index:
- The original implementation class of a gRPC service not foun
- Couldn't find id field of ${classInfo}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/f537b381bf9c60f2.
Report an issue: GitHub.