quarkusio/quarkus · error · IllegalStateException

Should be implemented!

Error message

Should be implemented!

What it means

DevResourceLifecycleManager.container(T) is a default method intended to be overridden by implementations that know how to create their container from config. The default body throws IllegalStateException('Should be implemented!') to signal that the concrete lifecycle manager forgot to provide container creation logic.

Source

Thrown at extensions/observability-devservices/testlibs/devresource-common/src/main/java/io/quarkus/observability/devresource/DevResourceLifecycleManager.java:63

    /**
     * Should we enable / start this dev resource.
     * e.g. we could already have actual service running
     * Each impl should provide its own reason on why it disabled dev service.
     *
     * @return true if ok to start new dev service, false otherwise
     */
    default boolean enable() {
        return true;
    }

    /**
     * Create container from config.
     *
     * @param config the config
     * @return container id
     */
    default Container<T> container(T config) {
        throw new IllegalStateException("Should be implemented!");
    }

    /**
     * Create container from config.
     *
     * @param config the config
     * @param root the all modules config
     * @return container id
     */
    default Container<T> container(T config, ModulesConfiguration root) {
        return container(config);
    }

    /**
     * Deduce current config from params.
     * If port are too dynamic / configured, it's hard to deduce,
     * since configuration is not part of the devservice state.
     * e.g. different ports then usual - Grafana UI is 3000, if you do not use 3000,

View on GitHub (pinned to e1c734241f)

Solutions

  1. Override container(T config) in your DevResourceLifecycleManager implementation and return a started GenericContainer
  2. Extend a concrete manager subclass that already implements container()
  3. If you don't need a container, override related lifecycle methods to avoid the default being called

Example fix

// before
class MyManager implements DevResourceLifecycleManager<MyConfig> { }
// after
class MyManager implements DevResourceLifecycleManager<MyConfig> {
    @Override
    public GenericContainer<?> container(MyConfig config) {
        return new GenericContainer<>("my-image").withExposedPorts(8080);
    }
}
Defensive patterns

Strategy: type-guard

Validate before calling

DevResourceLifecycleManager<?> m = ...;
// ensure the concrete class overrides container():
if (m.getClass().getMethod("container", Object.class).getDeclaringClass() == DevResourceLifecycleManager.class) {
    throw new IllegalStateException(m.getClass() + " must override container()");
}

Type guard

static boolean implementsContainer(DevResourceLifecycleManager<?> m) throws NoSuchMethodException {
    return m.getClass().getMethod("container", Object.class).getDeclaringClass() != DevResourceLifecycleManager.class;
}

Try / catch

try { Container<?> c = manager.container(config); } catch (IllegalStateException e) { if ("Should be implemented!".equals(e.getMessage())) { /* use fallback container */ } }

Prevention

When it happens

Trigger: Using (or extending) a DevResourceLifecycleManager that does not override container(config), and the framework invoking the default method during dev-service/test-resource startup.

Common situations: Custom observability dev resource manager created by copying a base class without implementing container(); abstract helpers left unimplemented; API version changes where a new method must be overridden.

Related errors


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