[jboss-jira] [JBoss JIRA] (WFLY-9235) @Resource injection does not fail in a servlet when the resource is missing

Stephen Coy (JIRA) issues at jboss.org
Thu Aug 17 10:20:00 EDT 2017


    [ https://issues.jboss.org/browse/WFLY-9235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13450852#comment-13450852 ] 

Stephen Coy commented on WFLY-9235:
-----------------------------------

I found this comment in org.jboss.as.ee.component.deployers.ResourceInjectionAnnotationParsingProcessor:

{quote}            // if it's an env-entry type then we do *not* create a BindingConfiguration to bind to the ENC
            // since the binding (value) for env-entry is always driven from a deployment descriptor.
            // The deployment descriptor processing and subsequent binding in the ENC is taken care off by a
            // different Deployment unit processor. If the value isn't specified in the deployment descriptor,
            // then there will be no binding the ENC and that's what is expected by the Java EE 6 spec. Furthermore,
            // if the @Resource is an env-entry binding then the injection target will be optional since in the absence of
            // an env-entry-value, there won't be a binding and effectively no injection. This again is as expected by spec.
{quote}



> @Resource injection does not fail in a servlet when the resource is missing
> ---------------------------------------------------------------------------
>
>                 Key: WFLY-9235
>                 URL: https://issues.jboss.org/browse/WFLY-9235
>             Project: WildFly
>          Issue Type: Bug
>          Components: Naming, Web (Undertow)
>            Reporter: Stephen Coy
>            Assignee: Stuart Douglas
>         Attachments: web45709634.jira.zip
>
>
> The attached web application builds, deploys and runs perfectly.
> However, if you remove one of the <env-entry> elements from the web.xml it will still deploy and run.
> The associated injection point is left as null instead of having the deployment fail as required by the Java EE 7 Spec in "EE.5.2.5 Annotations and Injection", where it states:
> {quote} If the container fails to find a resource needed for injection, initialization of the class must fail, and the class must not be put into service.{quote}
> Also see StackOverflow question https://stackoverflow.com/questions/45716813/glassfish-wildfly-not-failing-if-resource-cannot-be-resolved



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list