[jboss-jira] [JBoss JIRA] (WFLY-11858) [Wildfly16] CDI fails to inject InitialContext during startup
Laird Nelson (Jira)
issues at jboss.org
Wed Mar 20 11:58:00 EDT 2019
[ https://issues.jboss.org/browse/WFLY-11858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13711108#comment-13711108 ]
Laird Nelson commented on WFLY-11858:
-------------------------------------
{{AbstractBean}} instances are [in {{Dependent}} scope by default|https://github.com/jbosstm/narayana/blob/5.9.3.Final/ArjunaJTA/cdi/classes/com/arjuna/ats/jta/cdi/AbstractBean.java#L85-L88]. Therefore {{JNDIBean}} instances are also in {{Dependent}} scope by default, unless they override the {{getScope()}} method. Indeed, the {{AbstractBean}} subclass created for {{InitialContext}} [overrides the scope to be {{Singleton}}|https://github.com/jbosstm/narayana/blob/5.9.3.Final/ArjunaJTA/cdi/classes/com/arjuna/ats/jta/cdi/TransactionExtension.java#L95-L98].
This means that anyone can {{@Inject}} an {{InitialContext}}, for example, and will receive a singleton at the injection point, and multiple creations of {{InitialContext}} will not happen.
If for some reason that is illegal or not desired or anything else, you can change this line: https://github.com/jbosstm/narayana/blob/5.9.3.Final/ArjunaJTA/cdi/classes/com/arjuna/ats/jta/cdi/JNDIBean.java#L76
If you eliminate the line, then the scope will be {{Dependent}} once again and a new {{InitialContext}} will be created for each injection point referencing {{InitialContext}}. That obviously has pros and cons.
I have [another pull request open|https://github.com/jbosstm/narayana/pull/1403] where I could roll in any change that anyone wants here.
> [Wildfly16] CDI fails to inject InitialContext during startup
> -------------------------------------------------------------
>
> Key: WFLY-11858
> URL: https://issues.jboss.org/browse/WFLY-11858
> Project: WildFly
> Issue Type: Bug
> Components: CDI / Weld, Transactions
> Affects Versions: 16.0.0.Final
> Reporter: Rakesh K. Cherukuri
> Assignee: Matej Novotny
> Priority: Major
> Attachments: stacktrace.log
>
>
> We are in the process of upgrading from 14.0.1.Final. While Wildfly 15.0.1 works fine, 16.0.0.Final is intermittently (3 out of 5 times) failing to start with following error
> _WELD-001334: Unsatisfied dependencies for type InitialContext with qualifiers_
> In our application, a bootstrap servlet startsup services (Stateless EJBs) during server startup. During this process the server fails to start with above error.
> Basically CDI is not able to find the appropriate InitialContext bean *intermittently*. This is not failing in our application code but in the wildfly libraries itself.
> Any pointers on this will be helpful. Don't want to end up with startup issues in stage/production :)
> Unfortunately my efforts to come up with a simplified maven module to showcase the error didn't succeed. So, please let me know if any further information is required and i will be glad to fill it in.
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
More information about the jboss-jira
mailing list