quarkusio/quarkus · error · IllegalArgumentException

Couldn't find id field of

Error message

Couldn't find id field of 

What it means

The REST Data Panache deployment must know which field is the entity's identifier to generate resource methods. It walks the class hierarchy looking for a field named 'id' and throws IllegalArgumentException when none is found.

Source

Thrown at extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/main/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/EntityClassHelper.java:42

    public FieldInfo getIdField(String className) {
        return getIdField(index.getClassByName(DotName.createSimple(className)));
    }

    private FieldInfo getIdField(ClassInfo classInfo) {
        ClassInfo tmpClassInfo = classInfo;
        while (tmpClassInfo != null) {
            for (FieldInfo field : tmpClassInfo.fields()) {
                if (field.hasAnnotation(DotName.createSimple(Id.class.getName()))) {
                    return field;
                }
            }
            if (tmpClassInfo.superName() != null) {
                tmpClassInfo = index.getClassByName(tmpClassInfo.superName());
            } else {
                tmpClassInfo = null;
            }
        }
        throw new IllegalArgumentException("Couldn't find id field of " + classInfo);
    }

    public MethodDescriptor getSetter(String className, FieldInfo field) {
        return getSetter(index.getClassByName(DotName.createSimple(className)), field);
    }

    private MethodDescriptor getSetter(ClassInfo entityClass, FieldInfo field) {
        MethodDescriptor setter = getMethod(entityClass, JavaBeanUtil.getSetterName(field.name()), field.type());
        if (setter != null) {
            return setter;
        }
        return MethodDescriptor.ofMethod(entityClass.toString(),
                EnhancerConstants.PERSISTENT_FIELD_WRITER_PREFIX + field.name(), void.class, field.type().name().toString());
    }

    private MethodDescriptor getMethod(ClassInfo entityClass, String name, Type... parameters) {
        if (entityClass == null) {
            return null;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Declare an explicit identifier field named id in the entity (e.g. @Id public ObjectId id;)
  2. If the key must be named differently, rename it to id or use a non-Panache REST data approach
  3. Ensure the entity class and its superclasses are in the Jandex index (add a Jandex index if in an external jar)

Example fix

// before
public class Customer {
    public String customerId;
}
// after
public class Customer {
    @Id
    public ObjectId id;
}
Defensive patterns

Strategy: validation

Validate before calling

boolean hasId = Arrays.stream(Customer.class.getFields()).anyMatch(f -> f.getName().equals("id"));
if (!hasId) throw new IllegalStateException("Entity must expose an 'id' field for REST Data Panache");

Prevention

When it happens

Trigger: An entity referenced by a Panache REST Data resource has no field named id in the class or any indexed superclass, so getIdField exhausts the hierarchy and throws.

Common situations: Custom entity with a differently named key field (e.g. userId, uuid); missing @Id annotation; entity superclasses not present in the Jandex index.

Related errors


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