users@javaee-spec.java.net

[javaee-spec users] [jsr366-experts] Re: Compatibility Problems with MR Resource Annotation Widening

From: Jason Greene <jason.greene_at_redhat.com>
Date: Thu, 5 Mar 2015 16:49:55 -0600

BTW Iím planning to reply to your other points and your other emails ASAP. I have just had a lot going atm. Just wanted you to know I am not ignoring the rest of your points.


> On Mar 5, 2015, at 4:45 PM, Jason Greene <jason.greene_at_redhat.com> wrote:
>
>
>> On Mar 5, 2015, at 4:19 PM, Bill Shannon <bill.shannon_at_oracle.com> wrote:
>>
>> Show me.
>>
>> I have a CDI bean that's @Injected in to a servlet, and the CDI bean declares
>> @Resource injected fields. The fields are injected into the bean and the bean
>> is injected into the servlet. It works fine.
>
> Create a Base.java:
>
> @ApplicationScoped
> public class Base {
>
> @Resource(name="java:module/env/myresource", lookup="java:comp/DefaultDataSource")
> DataSource ds;
> }
>
> Then an SLSB:
>
> @Stateless
> public class SLSB {
> @Inject Base base;
>
> @javax.annotation.PostConstruct
> public void setup() {
> System.out.println("========= BASE is = " + base.ds);
> }
>
> public void doSomething() throws Exception {
> System.out.println("========= BASE is = " + base.ds);
> }
> }
>
> Package them up in an ejb jar.
>
> I get null (using the EE7 RI update 1).
>
> It certainly could work, but only if you *know* Base.java is a CDI managed. To use an example, if there was an @Veteod on Base, it should not work.
>
> --
> Jason T. Greene
> WildFly Lead / JBoss EAP Platform Architect
> JBoss, a division of Red Hat
>

--
Jason T. Greene
WildFly Lead / JBoss EAP Platform Architect
JBoss, a division of Red Hat