quarkusio/quarkus · error · PanacheQueryException

Your application must be built with parameter names, this sh

Error message

Your application must be built with parameter names, this should be the default if using Quarkus project generation. Check the Maven or Gradle compiler configuration to include '-parameters'. When using Kotlin data classes with value classes or default parameters, Panache skips synthetic constructors automatically; if this error persists, annotate the constructor with @ProjectedConstructor or annotate parameters with @ProjectedFieldName.

What it means

ProjectionConstructorUtil.getProjectionParameterName needs the Java reflection parameter name to map a select item to the DTO constructor parameter. If Parameter.isNamePresent() is false — meaning the class was compiled without the -parameters flag (and no @ProjectedFieldName/@ProjectedConstructor annotations help) — Panache throws this descriptive exception explaining the build configuration fix and the annotation fallbacks.

Source

Thrown at extensions/panache/panache-hibernate-common/runtime/src/main/java/io/quarkus/panache/hibernate/common/runtime/ProjectionConstructorUtil.java:110

            return selectedConstructor;
        }

        for (Constructor<?> constructor : constructors) {
            if (constructor.getParameterCount() > 0) {
                throw new PanacheQueryException(buildNoSuitableConstructorMessage(type, constructor));
            }
        }
        throw new PanacheQueryException("No suitable projection constructor found for " + type.getName()
                + ". Projection DTOs require a constructor with at least one parameter.");
    }

    public static String getProjectionParameterName(Class<?> parentType, String parentParameter, Parameter parameter,
            BiFunction<Class<?>, String, String> nestedProjectionBuilder) {
        String parameterName;
        if (hasProjectedFieldName(parameter)) {
            parameterName = getNameFromProjectedFieldName(parameter);
        } else if (!parameter.isNamePresent()) {
            throw new PanacheQueryException(
                    "Your application must be built with parameter names, this should be the default if"
                            + " using Quarkus project generation. Check the Maven or Gradle compiler configuration to include '-parameters'."
                            + " When using Kotlin data classes with value classes or default parameters, Panache skips synthetic"
                            + " constructors automatically; if this error persists, annotate the constructor with @ProjectedConstructor"
                            + " or annotate parameters with @ProjectedFieldName.");
        } else {
            try {
                Field field = parentType.getDeclaredField(parameter.getName());
                parameterName = hasProjectedFieldName(field) ? getNameFromProjectedFieldName(field)
                        : parameter.getName();
            } catch (NoSuchFieldException e) {
                parameterName = parameter.getName();
            }
        }
        parameterName = parentParameter == null ? parameterName : parentParameter + "." + parameterName;
        if (hasNestedProjectedClass(parameter.getType())) {
            return nestedProjectionBuilder.apply(parameter.getType(), parameterName);
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Enable -parameters in the compiler config: Maven maven-compiler-plugin <parameters>true</parameters> or Gradle tasks.withType(JavaCompile) { options.compilerArgs += ['-parameters'] }
  2. Annotate each constructor parameter with @ProjectedFieldName("entityFieldName") to supply names explicitly
  3. Annotate the constructor with @ProjectedConstructor so Panache selects and maps it explicitly
  4. If the DTO is in a third-party jar, rebuild it with -parameters or use annotation-based mapping via a local wrapper DTO
  5. For Kotlin, avoid synthetic constructors (value classes/default params) or use the annotations above

Example fix

// before (Maven)
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
</plugin>

// after
<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <parameters>true</parameters>
  </configuration>
</plugin>
Defensive patterns

Strategy: validation

Validate before calling

// fail fast at startup if the DTO lacks parameter names
static void assertParameterNamesAvailable(Class<?> dto) throws NoSuchMethodException {
    for (java.lang.reflect.Constructor<?> c : dto.getConstructors()) {
        if (c.getParameterCount() > 0 && !c.getParameters()[0].isNamePresent()) {
            throw new IllegalStateException("Compile with -parameters or annotate " + dto + " with @ProjectedFieldName");
        }
    }
}

Try / catch

try {
    return query.project(Dto.class).list();
} catch (PanacheQueryException e) {
    if (e.getMessage().contains("-parameters")) {
        throw new IllegalStateException("Build configuration problem: enable -parameters", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Using project(Dto.class) where the DTO class was compiled without -parameters and constructor parameters have no @ProjectedFieldName annotations; common when the DTO comes from a dependency jar or a Kotlin module with synthetic constructors.

Common situations: Maven/Gradle project not using Quarkus project generation defaults (compiler plugin lacks <parameters>true</parameters> or compileJava { options.compilerArgs << '-parameters' }); DTOs built in a separate module or library without -parameters; Kotlin data classes with value classes/default parameters where synthetic constructors were not skipped.

Related errors


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