quarkusio/quarkus · error · IllegalArgumentException

Only instances of SmallRyeContextManager are supported:

Error message

Only instances of SmallRyeContextManager are supported: 

What it means

QuarkusContextManagerProvider only accepts SmallRyeContextManager instances; the MicroProfile ContextProvider SPI allows registering arbitrary ContextManager implementations, but Quarkus's provider implementation must keep a reference to the concrete SmallRye type, so anything else is rejected with an IllegalArgumentException.

Source

Thrown at extensions/smallrye-context-propagation/runtime/src/main/java/io/quarkus/smallrye/context/runtime/QuarkusContextManagerProvider.java:33

    @Override
    public SmallRyeContextManager getContextManager(ClassLoader classLoader) {
        return contextManager;
    }

    @Override
    public SmallRyeContextManager getContextManager() {
        return contextManager;
    }

    @Override
    public ContextManager findContextManager(ClassLoader classLoader) {
        return contextManager;
    }

    @Override
    public void registerContextManager(ContextManager manager, ClassLoader classLoader) {
        if (manager instanceof SmallRyeContextManager == false) {
            throw new IllegalArgumentException("Only instances of SmallRyeContextManager are supported: " + manager);
        }
        contextManager = (SmallRyeContextManager) manager;
    }

    @Override
    public void releaseContextManager(ContextManager manager) {
        contextManager = null;
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Do not register a custom ContextManager on Quarkus — use the built-in one provided by the extension
  2. Wrap your functionality in a ThreadContextProvider instead of a full ContextManager
  3. Ensure no dependency (e.g. another MP Context Propagation implementation) is calling registerContextManager with a foreign manager; exclude or reconfigure it

Example fix

// before
ContextManagerProvider.provider().registerContextManager(myCustomManager, cl);
// after
// do nothing — Quarkus manages its own SmallRyeContextManager
// or contribute a ThreadContextProvider via META-INF/services
Defensive patterns

Strategy: type-guard

Validate before calling

if (manager instanceof SmallRyeContextManager) {
    ContextManagerProvider.provider().registerContextManager(manager, cl);
}

Type guard

boolean isSmallRye(ContextManager m) { return m instanceof SmallRyeContextManager; }

Try / catch

try { provider.registerContextManager(manager, cl); }
catch (IllegalArgumentException e) { log.error("Quarkus only accepts SmallRyeContextManager", e); }

Prevention

When it happens

Trigger: Calling ContextManagerProvider.registerContextManager(manager, classLoader) (or triggering it via an extension/library that does) with a custom or mock ContextManager that is not a SmallRyeContextManager.

Common situations: Integrating a third-party context library that installs its own ContextManager; tests registering a mocked ContextManager; duplicate provider registration ordering where a foreign implementation wins.

Related errors


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