Unproxyable @ApplicationScoped bean silently behaves as @Dependent

Open
#35 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
54/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java
Domain
backend

Research direction

Start by tracing how @ApplicationScoped beans are processed and how CDI resolution handles unproxyable bean types in micronaut-odi-cdi and micronaut-odi-processor-cdi; the issue does not name specific files or tests. Reproduce with the supplied NoDefaultCtor example and check whether startup or Instance.get() reports an UnproxyableResolutionException instead of silently creating dependent instances.

Written by the indexing model from the issue text.

Description

ODI 1.0.0 (micronaut-odi-cdi + micronaut-odi-processor-cdi from Maven Central), Temurin 25.0.5.

@Dependent
public class Helper { }

@ApplicationScoped
public class NoDefaultCtor {
    private int hits;
    @Inject public NoDefaultCtor(Helper helper) { }  // no no-arg constructor
    public int hit() { return ++hits; }
}

SeContainer c = SeContainerInitializer.newInstance().initialize();
NoDefaultCtor a = c.select(NoDefaultCtor.class).get();
NoDefaultCtor b = c.select(NoDefaultCtor.class).get();
// a != b, a.hit() == 1, b.hit() == 1, a.getClass() == NoDefaultCtor (no client proxy)

Injecting it into a @Dependent bean (@Inject NoDefaultCtor injected;) also gives a new instance per consumer.

Expected (CDI 4.1, "Unproxyable bean types"): the class has no non-private no-arg constructor, so it cannot be proxied. An injection point resolving to it is a deployment problem, and Instance.get() throws UnproxyableResolutionException.

Actual: compilation and startup succeed with no warning, and every lookup or injection creates a new instance, so the scope is silently lost.

This reproduces with a plain 5-class project and no interceptors; happy to attach it.

Dominant language
Java
Stars
13
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from eclipse-ee4j/odi

All issues in eclipse-ee4j/odi

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.