quarkusio/quarkus · error · IllegalArgumentException

Class + configPropertiesClassInfo + which is annotated wit

Error message

Class  + configPropertiesClassInfo +  which is annotated with  + ConfigurationPropertiesProcessor.CONFIGURATION_PROPERTIES +  must contain a no-arg constructor

What it means

Spring Boot style @ConfigurationProperties classes bound by the quarkus-spring-boot-properties extension need to be instantiated reflectively. When no custom instance factory is provided, the class must have a no-arg constructor; otherwise Quarkus cannot create the config object at build time and fails the build.

Source

Thrown at extensions/spring-boot-properties/deployment/src/main/java/io/quarkus/spring/boot/properties/deployment/ClassConfigurationPropertiesUtil.java:165

                                        String.class),
                                bc.get(mc.this_().field(configClassToFieldDesc.get(configClass))));
                    }
                    bc.return_(); // the method doesn't need to do anything
                });
            });
        });
    }

    /**
     * @return true if the configuration class needs validation
     */
    boolean addProducerMethodForClassConfigProperties(ClassLoader classLoader, ClassInfo configPropertiesClassInfo,
            String prefixStr, ConfigMapping.NamingStrategy namingStrategy,
            boolean failOnMismatchingMember,
            ConfigurationPropertiesMetadataBuildItem.InstanceFactory instanceFactory) {

        if ((instanceFactory == null) && !configPropertiesClassInfo.hasNoArgsConstructor()) {
            throw new IllegalArgumentException(
                    "Class " + configPropertiesClassInfo + " which is annotated with "
                            + ConfigurationPropertiesProcessor.CONFIGURATION_PROPERTIES
                            + " must contain a no-arg constructor");
        }

        String configObjectClassStr = configPropertiesClassInfo.name().toString();

        boolean needsValidation = needsValidation();
        String[] produceMethodParameterTypes = new String[needsValidation ? 2 : 1];
        produceMethodParameterTypes[0] = Config.class.getName();
        if (needsValidation) {
            produceMethodParameterTypes[1] = VALIDATOR_CLASS;
        }

        /*
         * Add a method like this:
         *
         * @Produces

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add a public no-arg constructor to the @ConfigurationProperties class.
  2. Register a custom InstanceFactory (ConfigurationPropertiesMetadataBuildItem.InstanceFactory) if the class cannot have a no-arg constructor.
  3. Add @NoArgsConstructor (Lombok) or a default constructor while keeping setters for binding.

Example fix

// before
@ConfigurationProperties("app")
public class AppProps {
    private final String name;
    public AppProps(String name) { this.name = name; }
}
// after
@ConfigurationProperties("app")
public class AppProps {
    private String name;
    public AppProps() { }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
}
Defensive patterns

Strategy: validation

Validate before calling

static void checkNoArgConstructor(Class<?> propsClass) {
    if (Arrays.stream(propsClass.getDeclaredConstructors())
            .noneMatch(c -> c.getParameterCount() == 0 && Modifier.isPublic(c.getModifiers()))) {
        throw new IllegalArgumentException(propsClass + " needs a public no-arg constructor");
    }
}

Prevention

When it happens

Trigger: addProducerMethodForClassConfigProperties is invoked (via needsValidation) for a @ConfigurationProperties-annotated class that lacks a public no-arg constructor and no InstanceFactory build item was registered.

Common situations: Migrating a Spring Boot app to Quarkus where the properties class uses constructor binding / @AllArgsConstructor without keeping a default constructor; Kotlin or Lombok classes generating only parameterized constructors.

Related errors


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