quarkusio/quarkus · error · RuntimeException

RuntimeException(e)

Error message

RuntimeException(e)

What it means

QueryObjectReader.create() instantiates the target POJO via its no-arg constructor using reflection. Any failure (missing no-arg constructor, constructor throwing, access violation) is wrapped in a RuntimeException. Inspect the cause for the actual problem.

Source

Thrown at extensions/funqy/funqy-server-common/runtime/src/main/java/io/quarkus/funqy/runtime/query/QueryObjectReader.java:24

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

/**
 * Turn URI parameter map into an object
 *
 */
class QueryObjectReader extends BaseObjectReader {

    Map<String, ValueSetter> properties = new HashMap<>();
    Class clz;

    @Override
    public Object create() {
        try {
            return clz.getDeclaredConstructor().newInstance();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    QueryObjectReader(Class clz, QueryObjectMapper mapper) {
        this.clz = clz;
        for (Method m : clz.getMethods()) {
            if (!isSetter(m))
                continue;
            Class paramType = m.getParameterTypes()[0];
            Type paramGenericType = m.getGenericParameterTypes()[0];
            final Function<String, Object> extractor = mapper.extractor(paramType);

            String name;
            if (m.getName().length() > 4) {
                name = Character.toLowerCase(m.getName().charAt(3)) + m.getName().substring(4);
            } else {
                name = m.getName().substring(3).toLowerCase();
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add a public no-argument constructor to the parameter POJO
  2. Move validation/initialization logic out of the constructor into setters or the function body
  3. Make inner classes static or top-level
  4. Use the query parameter binding-friendly mutable POJO pattern

Example fix

// before
public class Params {
    public Params(String name) { this.name = name; } // no no-arg ctor
}
// after
public class Params {
    public Params() {}
    public void setName(String name) { this.name = name; }
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify POJO has a public no-arg constructor before binding
static void assertInstantiable(Class<?> clz) {
    try {
        clz.getDeclaredConstructor().setAccessible(true);
    } catch (NoSuchMethodException e) {
        throw new IllegalArgumentException(clz + " needs a public no-arg constructor");
    }
}

Type guard

static boolean hasNoArgConstructor(Class<?> clz) {
    try { clz.getDeclaredConstructor(); return true; }
    catch (NoSuchMethodException e) { return false; }
}

Try / catch

try {
    Object pojo = reader.create();
} catch (RuntimeException e) {
    Throwable cause = e.getCause();
    if (cause instanceof InstantiationException || cause instanceof NoSuchMethodException)
        log.errorf("Add a public no-arg constructor to %s", clz.getName());
    throw e;
}

Prevention

When it happens

Trigger: A @Funq query function parameter POJO without a public no-argument constructor, or whose constructor throws (e.g. validation in constructor).

Common situations: Defining immutable POJOs with only builder/args constructors for query binding; constructor performing IO or validation that fails; inner non-static classes lacking no-arg constructors.

Related errors


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