apache/maven · error · IllegalStateException
No instance of ${clazz.getName()} is bound to the session sc
Error message
No instance of ${clazz.getName()} is bound to the session scope. What it means
SessionScope.seededKeySupplier is the fallback supplier bound for session-scoped keys. When such a key is resolved and no real instance has been seeded or computed for the current session scope state, the supplier throws IllegalStateException("No instance of <class> is bound to the session scope.") — the session scope holds no binding for that type.
Source
Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/di/SessionScope.java:185
return value;
}
@Override
public T get() {
if (value == null) {
synchronized (this) {
if (value == null) {
value = provider.get();
}
}
}
return value;
}
}
public static <T> Supplier<T> seededKeySupplier(Class<? extends T> clazz) {
return () -> {
throw new IllegalStateException("No instance of " + clazz.getName() + " is bound to the session scope.");
};
}
}
View on GitHub (pinned to e4093d4e12)
Solutions
- Seed the instance before resolution: sessionScope.enter(); sessionScope.seed(MyComponent.class, instance);
- Bind the type normally (unscoped or session-scoped with a real provider) instead of relying on the seeded placeholder key
- Resolve the dependency lazily inside the session lifecycle, after Maven has seeded it
Example fix
// before sessionScope.enter(); MyComponent c = injector.getInstance(MyComponent.class); // IllegalStateException: not seeded // after sessionScope.enter(); sessionScope.seed(MyComponent.class, new MyComponentImpl()); MyComponent c = injector.getInstance(MyComponent.class);
Defensive patterns
Strategy: validation
Validate before calling
// seed the session scope before resolving the key
sessionScope.enter();
try {
sessionScope.seed(MyComponent.class, new MyComponentImpl());
MyComponent c = injector.getInstance(MyComponent.class);
} finally {
sessionScope.exit();
} Try / catch
try {
MyComponent c = injector.getInstance(MyComponent.class);
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().contains("session scope")) {
throw new IllegalStateException("MyComponent must be seeded into the session scope first", e);
}
throw e;
} Prevention
- Bind session-scoped types with real providers instead of placeholder seeded keys
- Seed required instances right after sessionScope.enter()
- Prefer resolving dependencies during the session lifecycle, not at container startup
When it happens
Trigger: Resolving a session-scoped key before SessionScope.seed(...) provided the instance; bindings that reference the seeded key directly instead of going through the scope's scope() wrapper; resolving after exit() dropped the seeded values.
Common situations: Test setups binding a placeholder key but forgetting seed(); components depending on a session-scoped type that Maven never seeds in the current lifecycle phase; refactors renaming seeded classes so old keys remain bound to placeholders.
Related errors
- Cannot access session scope outside of a scoping block
- No instance of {} is bound to the mojo execution scope.
- Cannot access {} outside of a scoping block
- Error while initializing binding {}
- Cannot rebind scope annotation class to a different implemen
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/e1fb2672fc00e946.
Report an issue: GitHub.