Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Injection in EJB interceptors is not working  #3

@agori

Description

@agori

PersistenceContext is not injected in EJB interceptors, and throws NullPointerException when I try to access the EntityManager.
This issue forces me to rewrite all the interceptors.

public class MyInterceptor {

    @PersistenceContext EntityManager em;

    @AroundInvoke
    public Object handle(InvocationContext context) throws Exception {
        try {
            return context.proceed();
        } finally {
            em.flush();  // throws NPE!
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions