apache/maven · error · IllegalArgumentException

The use of session scoped proxies require a org.apache.maven

Error message

The use of session scoped proxies require a org.apache.maven.api.di.Typed, org.eclipse.sisu.Typed or javax.enterprise.inject.Typed annotation

What it means

SessionScope can only create proxies for session-scoped classes when it can determine the interfaces to proxy, which requires a recognized @Typed annotation: org.apache.maven.api.di.Typed, org.eclipse.sisu.Typed, or javax.enterprise.inject.Typed. If none is present on a class being proxied, IllegalArgumentException is thrown stating the annotation is required.

Source

Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/di/SessionScope.java:146

                            (Class<?>[]) annotationType.getMethod("value").invoke(a);
                    if (value.length == 0) {
                        // Only direct interfaces implemented by the class
                        value = superType.getInterfaces();
                    }
                    List<Class<?>> nonInterfaces =
                            Stream.of(value).filter(c -> !c.isInterface()).toList();
                    if (!nonInterfaces.isEmpty()) {
                        throw new IllegalArgumentException(
                                "The Typed annotation must contain only interfaces but the following types are not: "
                                        + nonInterfaces);
                    }
                    return value;
                } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
                    throw new IllegalStateException(e);
                }
            }
        }
        throw new IllegalArgumentException(
                "The use of session scoped proxies require a org.apache.maven.api.di.Typed, org.eclipse.sisu.Typed or javax.enterprise.inject.Typed annotation");
    }

    protected boolean isTypeAnnotation(Class<? extends Annotation> annotationType) {
        return "org.apache.maven.api.di.Typed".equals(annotationType.getName());
    }

    /**
     * A provider wrapping an existing provider with a cache
     * @param <T> the provided type
     */
    protected static class CachingProvider<T> implements Supplier<T> {
        private final Supplier<T> provider;
        private volatile T value;

        CachingProvider(Supplier<T> provider) {
            this.provider = provider;
        }

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Add @Typed(...) to the session-scoped class, importing org.apache.maven.api.di.Typed (or org.eclipse.sisu.Typed)
  2. List the service interfaces in the value: @Typed(MyService.class)
  3. Verify the annotation is one of the three supported FQCNs — a same-shaped custom annotation is ignored

Example fix

// before
@SessionScoped
public class MyServiceImpl implements MyService { ... }

// after
import org.apache.maven.api.di.Typed;

@SessionScoped
@Typed(MyService.class)
public class MyServiceImpl implements MyService { ... }
Defensive patterns

Strategy: validation

Validate before calling

// verify the annotation is one Maven recognizes before the proxy is built
static boolean hasRecognizedTyped(Class<?> c) {
    for (Annotation a : c.getAnnotations()) {
        String n = a.annotationType().getName();
        if ("org.apache.maven.api.di.Typed".equals(n)
                || "org.eclipse.sisu.Typed".equals(n)
                || "javax.enterprise.inject.Typed".equals(n)) return true;
    }
    return false;
}
if (!hasRecognizedTyped(MyServiceImpl.class)) throw new IllegalStateException("Missing @Typed on session-scoped class");

Prevention

When it happens

Trigger: Marking a class @SessionScoped (or otherwise proxied by SessionScope) without any @Typed annotation; using a custom Typed annotation whose FQCN is not one of the three recognized names (isTypeAnnotation() matches by name).

Common situations: New session-scoped components written without the annotation; migrating code from javax to jakarta-style annotations and picking an unrecognized Typed; renaming packages so the annotation FQCN no longer matches.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/1910c932254fd703. Report an issue: GitHub.