apache/maven · error · DIException

Not allowed to call injectable method {}

Error message

Not allowed to call injectable method {}

What it means

Error "Not allowed to call injectable method {}" thrown in apache/maven.

Source

Thrown at impl/maven-di/src/main/java/org/apache/maven/di/impl/ReflectionUtils.java:260

            }
        };
    }

    public static <T> BindingInitializer<T> methodInjector(Key<T> container, Method method) {
        method.setAccessible(true);
        Dependency<?>[] dependencies = toDependencies(container.getType(), method);
        return new BindingInitializer<T>(new HashSet<>(Arrays.asList(dependencies))) {
            @Override
            public Consumer<T> compile(Function<Dependency<?>, Supplier<?>> compiler) {
                return instance -> {
                    Object[] args = getDependencies().stream()
                            .map(compiler)
                            .map(Supplier::get)
                            .toArray();
                    try {
                        method.invoke(instance, args);
                    } catch (IllegalAccessException e) {
                        throw new DIException("Not allowed to call injectable method " + method, e);
                    } catch (InvocationTargetException e) {
                        throw new DIException("Failed to call injectable method " + method, e.getCause());
                    }
                };
            }
        };
    }

    public static Dependency<?>[] toDependencies(@Nullable Type container, Executable executable) {
        Dependency<?>[] keys = toArgDependencies(container, executable);
        if (executable instanceof Constructor || Modifier.isStatic(executable.getModifiers())) {
            return keys;
        } else {
            Dependency<?>[] nkeys = new Dependency[keys.length + 1];
            nkeys[0] = new Dependency<>(Key.ofType(container), false);
            System.arraycopy(keys, 0, nkeys, 1, keys.length);
            return nkeys;
        }

View on GitHub (pinned to e4093d4e12)

When it happens

Trigger: Thrown at impl/maven-di/src/main/java/org/apache/maven/di/impl/ReflectionUtils.java:260 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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