CDI Injection in EntityListener fails when AttributeConverter is present during deployment #3720
Labels
Status: Accepted
Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev
Type: Bug
Label issue as a bug defect
Milestone
Description
CDI injection into an
EntityListener
fails if you also use anAttributeConverter
.This relates to my previously filled bug #3121. But this time i can reproduce it.
Expected Outcome
CDI injection into an entity listener always works.
Current Outcome
If you deploy a project with an
EntityListener
and anAttributeConverter
the injection into the listener fails.Steps to reproduce
Check out and build:
https://github.com/TheOnlyAl/entitylistener-bug
Deploy the war on Payara. Easiest way is to use the docker image:
docker run -p 4848:4848 -p 8080:8080 payara/server-full:5.184
After deployment you will see: "Could not inject AuditEntityListenerServiceBean!" in the log file.
If you remove the
Converter
from theEntity
here the injection works and you will get the date of the persist operation.Context
The only workaround currently is to remove all AttributeConverter's or do a manual lookup of the Bean in the EntityListener. In my example I use an EJB for the injection target, but CDI beans should also fail.
The problem is that if the JPADeployer finds any AttributeConverter's during deployment it tries to create the InjectionManager, which will fail since the BeanManager can not be looked up, and therefore fallback to the DisabledInjectionManager.
If no AttributeConverter is registered, the InjectionManager is created after the deployment and the BeanManager lookup does not fail. This is why the injection works fine without and AttributeConverter
I tested this on 5.183 and 5.184.
Environment
The text was updated successfully, but these errors were encountered: