quarkusio/quarkus · error · IllegalStateException

Unable to construct type for ${btRemovedBean}: ${e.getMessag

Error message

Unable to construct type for ${btRemovedBean}: ${e.getMessage()}

What it means

Arc's ComponentsProviderGenerator generates bytecode that enumerates beans removed since a previous build, including their runtime types. The RuntimeTypeCreator cannot convert the bean's Type into a runtime java.lang.reflect.Type (e.g. because parameterized types reference classes that cannot be loaded), so the generator wraps the IllegalArgumentException in this IllegalStateException. It is a build-time (deployment) failure, not a runtime one.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/ComponentsProviderGenerator.java:462

                            for (BeanInfo btRemovedBean : group.removedBeans()) {
                                // Bean types
                                LocalVar rtTypes = b0.localVar("types", b0.new_(HashSet.class));
                                for (Type btType : btRemovedBean.getTypes()) {
                                    if (DotNames.OBJECT.equals(btType.name())) {
                                        // Skip java.lang.Object
                                        continue;
                                    }

                                    b0.try_(tc -> {
                                        tc.body(b1 -> {
                                            try {
                                                LocalVar rtType = RuntimeTypeCreator.of(b1)
                                                        .withCache(typeCacheMap)
                                                        .withTCCL(tccl)
                                                        .create(btType);
                                                b1.withSet(rtTypes).add(rtType);
                                            } catch (IllegalArgumentException e) {
                                                throw new IllegalStateException("Unable to construct type for " + btRemovedBean
                                                        + ": " + e.getMessage());
                                            }
                                        });
                                        tc.catch_(Throwable.class, "e", (b1, e) -> {
                                            b1.invokeStatic(MethodDescs.COMPONENTS_PROVIDER_UNABLE_TO_LOAD_REMOVED_BEAN_TYPE,
                                                    Const.of(btType.toString()), e);
                                        });
                                    });
                                }

                                // Qualifiers
                                LocalVar rtQualifiers;
                                if (btRemovedBean.hasDefaultQualifiers() || btRemovedBean.getQualifiers().isEmpty()) {
                                    // No qualifiers or default qualifiers (@Any, @Default)
                                    rtQualifiers = b0.localVar("qualifiers", Const.ofNull(Set.class));
                                } else {
                                    rtQualifiers = b0.localVar("qualifiers", b0.new_(HashSet.class));

View on GitHub (pinned to e1c734241f)

Solutions

  1. Perform a clean rebuild (mvn clean or delete target/) so stale removed-bean metadata referencing unloadable types is discarded
  2. Restore/rebuild the class that the removed bean's generic type references so it is loadable by the TCCL
  3. Verify the bean's type does not use a type variable bound to a class missing from the application archive
  4. If reproducible, report/inspect the btRemovedBean name in the message to find the offending stale bean

Example fix

// before: incremental reload fails with stale removed bean
// after
mvn clean quarkus:dev
Defensive patterns

Strategy: validation

Validate before calling

// before build: ensure referenced generic types exist
class TypeCheck {
  static void checkLoadable(String className) throws IllegalStateException {
    try { Thread.currentThread().getContextClassLoader().loadClass(className); }
    catch (ClassNotFoundException e) { throw new IllegalStateException("Type not loadable: " + className, e); }
  }
}

Prevention

When it happens

Trigger: A removed bean's declared type references a parameterized/wildcard type whose raw class is not loadable via the thread context classloader during incremental-build removed-bean reconstruction (generateAddRemovedBeans inside createComponentsProvider).

Common situations: Live-reload / incremental compilation after deleting or renaming a bean class that had generic types; hot-redeployment where an old JBuildIndex still references classes that no longer exist on the TCCL.

Related errors


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