You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Vamsee Lakamsani <va...@yahoo.com.INVALID> on 2014/06/04 03:49:44 UTC
@Injected field of a @Injected field is null
I put together a small sample app here: https://github.com/lakamsani/cdi-nested
MyResource is a JAX-RS service into MyService is @Injected
MyDao is in-turn @Injected into MyService. When I run it (in TomEE 1.6.0.1), MyDao is null inside the MyService instance injected to MyResource. What do I need to do to make it work or is there another way of doing this (short of explicitly instantiating objects).
Re: @Injected field of a @Injected field is null
Posted by Romain Manni-Bucau <rm...@gmail.com>.
@John: this is not mandatory
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau
2014-06-04 17:42 GMT+02:00 John D. Ament <jo...@gmail.com>:
> You should annotate your REST endpoint to be something, e..g
> @Stateless or @RequestScoped
>
> On Wed, Jun 4, 2014 at 11:40 AM, Vamsee Lakamsani
> <va...@yahoo.com.invalid> wrote:
>> One of the null injection problems in our main app had to do with the fact that we are using Quartz directly and as expected injection won't work in a Quartz managed thread. We were able to workaround that by doing a JNDI lookup of our EJB in "java:global"
>>
>> Digressing a little bit, when we started looking at Quartz and TomEE we started off at this page:
>> http://tomee.apache.org/examples-trunk/quartz-app/README.html
>>
>>
>> We did not go the resource adapter route because the first few lines of that doc say to use the EJB 3.1 @Scheduler. But I have not been able to find any docs on how to setup TomEE to use a custom data source for scheduling info (like the Quartz clustered scheduler). It seems there is a feature Glassfish:
>> http://stackoverflow.com/questions/13292473/set-configure-the-ejb-timer-services-datasource
>>
>>
>>
>>
>> ________________________________
>> From: Andy Gumbrecht <ag...@tomitribe.com>
>> To: users@tomee.apache.org
>> Sent: Wednesday, June 4, 2014 1:58 AM
>> Subject: Re: @Injected field of a @Injected field is null
>>
>>
>> If you are using maven just replace version 1.6.0.1 with version
>> 1.7.0-SNAPSHOT in your pom.xml, else download it from here:
>> http://tomee.apache.org/download/tomee-1.7.0-snapshot.html
>>
>> Andy.
>>
>>
>> On 04/06/2014 07:52, Vamsee Lakamsani wrote:
>>> You are right. I pushed an update to my repo by adding a hello() business method. In the debugger MyDao becomes non-null when the method is entered.
>>> I do have a case in my larger app where I 'm seeing nulls even in the business method. Let me see if I can reproduce that in this small app.
>>>
>>> Thanks.
>>>
>>>
>>> ________________________________
>>> From: Romain Manni-Bucau <rm...@gmail.com>
>>> To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com>
>>> Sent: Tuesday, June 3, 2014 10:37 PM
>>> Subject: Re: @Injected field of a @Injected field is null
>>>
>>>
>>> works great on trunk.
>>>
>>> side note: bean instantiation is not done while ejb *business* method is
>>> not called for ejb and any method for cdi beans
>>>
>>>
>>>
>>> Romain Manni-Bucau
>>> Twitter: @rmannibucau
>>> Blog: http://rmannibucau.wordpress.com/
>>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>>> Github: https://github.com/rmannibucau
>>>
>>>
>>>
>>> 2014-06-04 3:49 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>>>
>>>> I put together a small sample app here:
>>>> https://github.com/lakamsani/cdi-nested
>>>>
>>>> MyResource is a JAX-RS service into MyService is @Injected
>>>> MyDao is in-turn @Injected into MyService. When I run it (in TomEE
>>>> 1.6.0.1), MyDao is null inside the MyService instance injected to
>>>> MyResource. What do I need to do to make it work or is there another way
>>>> of doing this (short of explicitly instantiating objects).
>>
>> --
>> Andy Gumbrecht
>>
>> http://www.tomitribe.com
>> agumbrecht@tomitribe.com
>> https://twitter.com/AndyGeeDe
>>
>> TomEE treibt Tomitribe! | http://tomee.apache.org
Re: @Injected field of a @Injected field is null
Posted by "John D. Ament" <jo...@gmail.com>.
You should annotate your REST endpoint to be something, e..g
@Stateless or @RequestScoped
On Wed, Jun 4, 2014 at 11:40 AM, Vamsee Lakamsani
<va...@yahoo.com.invalid> wrote:
> One of the null injection problems in our main app had to do with the fact that we are using Quartz directly and as expected injection won't work in a Quartz managed thread. We were able to workaround that by doing a JNDI lookup of our EJB in "java:global"
>
> Digressing a little bit, when we started looking at Quartz and TomEE we started off at this page:
> http://tomee.apache.org/examples-trunk/quartz-app/README.html
>
>
> We did not go the resource adapter route because the first few lines of that doc say to use the EJB 3.1 @Scheduler. But I have not been able to find any docs on how to setup TomEE to use a custom data source for scheduling info (like the Quartz clustered scheduler). It seems there is a feature Glassfish:
> http://stackoverflow.com/questions/13292473/set-configure-the-ejb-timer-services-datasource
>
>
>
>
> ________________________________
> From: Andy Gumbrecht <ag...@tomitribe.com>
> To: users@tomee.apache.org
> Sent: Wednesday, June 4, 2014 1:58 AM
> Subject: Re: @Injected field of a @Injected field is null
>
>
> If you are using maven just replace version 1.6.0.1 with version
> 1.7.0-SNAPSHOT in your pom.xml, else download it from here:
> http://tomee.apache.org/download/tomee-1.7.0-snapshot.html
>
> Andy.
>
>
> On 04/06/2014 07:52, Vamsee Lakamsani wrote:
>> You are right. I pushed an update to my repo by adding a hello() business method. In the debugger MyDao becomes non-null when the method is entered.
>> I do have a case in my larger app where I 'm seeing nulls even in the business method. Let me see if I can reproduce that in this small app.
>>
>> Thanks.
>>
>>
>> ________________________________
>> From: Romain Manni-Bucau <rm...@gmail.com>
>> To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com>
>> Sent: Tuesday, June 3, 2014 10:37 PM
>> Subject: Re: @Injected field of a @Injected field is null
>>
>>
>> works great on trunk.
>>
>> side note: bean instantiation is not done while ejb *business* method is
>> not called for ejb and any method for cdi beans
>>
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>>
>> 2014-06-04 3:49 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>>
>>> I put together a small sample app here:
>>> https://github.com/lakamsani/cdi-nested
>>>
>>> MyResource is a JAX-RS service into MyService is @Injected
>>> MyDao is in-turn @Injected into MyService. When I run it (in TomEE
>>> 1.6.0.1), MyDao is null inside the MyService instance injected to
>>> MyResource. What do I need to do to make it work or is there another way
>>> of doing this (short of explicitly instantiating objects).
>
> --
> Andy Gumbrecht
>
> http://www.tomitribe.com
> agumbrecht@tomitribe.com
> https://twitter.com/AndyGeeDe
>
> TomEE treibt Tomitribe! | http://tomee.apache.org
Re: @Injected field of a @Injected field is null
Posted by Vamsee Lakamsani <va...@yahoo.com.INVALID>.
One of the null injection problems in our main app had to do with the fact that we are using Quartz directly and as expected injection won't work in a Quartz managed thread. We were able to workaround that by doing a JNDI lookup of our EJB in "java:global"
Digressing a little bit, when we started looking at Quartz and TomEE we started off at this page:
http://tomee.apache.org/examples-trunk/quartz-app/README.html
We did not go the resource adapter route because the first few lines of that doc say to use the EJB 3.1 @Scheduler. But I have not been able to find any docs on how to setup TomEE to use a custom data source for scheduling info (like the Quartz clustered scheduler). It seems there is a feature Glassfish:
http://stackoverflow.com/questions/13292473/set-configure-the-ejb-timer-services-datasource
________________________________
From: Andy Gumbrecht <ag...@tomitribe.com>
To: users@tomee.apache.org
Sent: Wednesday, June 4, 2014 1:58 AM
Subject: Re: @Injected field of a @Injected field is null
If you are using maven just replace version 1.6.0.1 with version
1.7.0-SNAPSHOT in your pom.xml, else download it from here:
http://tomee.apache.org/download/tomee-1.7.0-snapshot.html
Andy.
On 04/06/2014 07:52, Vamsee Lakamsani wrote:
> You are right. I pushed an update to my repo by adding a hello() business method. In the debugger MyDao becomes non-null when the method is entered.
> I do have a case in my larger app where I 'm seeing nulls even in the business method. Let me see if I can reproduce that in this small app.
>
> Thanks.
>
>
> ________________________________
> From: Romain Manni-Bucau <rm...@gmail.com>
> To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com>
> Sent: Tuesday, June 3, 2014 10:37 PM
> Subject: Re: @Injected field of a @Injected field is null
>
>
> works great on trunk.
>
> side note: bean instantiation is not done while ejb *business* method is
> not called for ejb and any method for cdi beans
>
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-06-04 3:49 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>
>> I put together a small sample app here:
>> https://github.com/lakamsani/cdi-nested
>>
>> MyResource is a JAX-RS service into MyService is @Injected
>> MyDao is in-turn @Injected into MyService. When I run it (in TomEE
>> 1.6.0.1), MyDao is null inside the MyService instance injected to
>> MyResource. What do I need to do to make it work or is there another way
>> of doing this (short of explicitly instantiating objects).
--
Andy Gumbrecht
http://www.tomitribe.com
agumbrecht@tomitribe.com
https://twitter.com/AndyGeeDe
TomEE treibt Tomitribe! | http://tomee.apache.org
Re: @Injected field of a @Injected field is null
Posted by Andy Gumbrecht <ag...@tomitribe.com>.
If you are using maven just replace version 1.6.0.1 with version
1.7.0-SNAPSHOT in your pom.xml, else download it from here:
http://tomee.apache.org/download/tomee-1.7.0-snapshot.html
Andy.
On 04/06/2014 07:52, Vamsee Lakamsani wrote:
> You are right. I pushed an update to my repo by adding a hello() business method. In the debugger MyDao becomes non-null when the method is entered.
> I do have a case in my larger app where I 'm seeing nulls even in the business method. Let me see if I can reproduce that in this small app.
>
> Thanks.
>
>
> ________________________________
> From: Romain Manni-Bucau <rm...@gmail.com>
> To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com>
> Sent: Tuesday, June 3, 2014 10:37 PM
> Subject: Re: @Injected field of a @Injected field is null
>
>
> works great on trunk.
>
> side note: bean instantiation is not done while ejb *business* method is
> not called for ejb and any method for cdi beans
>
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-06-04 3:49 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>
>> I put together a small sample app here:
>> https://github.com/lakamsani/cdi-nested
>>
>> MyResource is a JAX-RS service into MyService is @Injected
>> MyDao is in-turn @Injected into MyService. When I run it (in TomEE
>> 1.6.0.1), MyDao is null inside the MyService instance injected to
>> MyResource. What do I need to do to make it work or is there another way
>> of doing this (short of explicitly instantiating objects).
--
Andy Gumbrecht
http://www.tomitribe.com
agumbrecht@tomitribe.com
https://twitter.com/AndyGeeDe
TomEE treibt Tomitribe! | http://tomee.apache.org
Re: @Injected field of a @Injected field is null
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Side note: CDI handling of JAXRS resources was totally rewritten on trunk
so can also be an issue so maybe have a try on trunk with your app if you
can.
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau
2014-06-04 7:52 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
> You are right. I pushed an update to my repo by adding a hello() business
> method. In the debugger MyDao becomes non-null when the method is entered.
> I do have a case in my larger app where I 'm seeing nulls even in the
> business method. Let me see if I can reproduce that in this small app.
>
> Thanks.
>
>
> ________________________________
> From: Romain Manni-Bucau <rm...@gmail.com>
> To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <
> vamsee@yahoo.com>
> Sent: Tuesday, June 3, 2014 10:37 PM
> Subject: Re: @Injected field of a @Injected field is null
>
>
> works great on trunk.
>
> side note: bean instantiation is not done while ejb *business* method is
> not called for ejb and any method for cdi beans
>
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-06-04 3:49 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>
> > I put together a small sample app here:
> > https://github.com/lakamsani/cdi-nested
> >
> > MyResource is a JAX-RS service into MyService is @Injected
> > MyDao is in-turn @Injected into MyService. When I run it (in TomEE
> > 1.6.0.1), MyDao is null inside the MyService instance injected to
> > MyResource. What do I need to do to make it work or is there another way
> > of doing this (short of explicitly instantiating objects).
>
Re: @Injected field of a @Injected field is null
Posted by Vamsee Lakamsani <va...@yahoo.com.INVALID>.
You are right. I pushed an update to my repo by adding a hello() business method. In the debugger MyDao becomes non-null when the method is entered.
I do have a case in my larger app where I 'm seeing nulls even in the business method. Let me see if I can reproduce that in this small app.
Thanks.
________________________________
From: Romain Manni-Bucau <rm...@gmail.com>
To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com>
Sent: Tuesday, June 3, 2014 10:37 PM
Subject: Re: @Injected field of a @Injected field is null
works great on trunk.
side note: bean instantiation is not done while ejb *business* method is
not called for ejb and any method for cdi beans
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau
2014-06-04 3:49 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
> I put together a small sample app here:
> https://github.com/lakamsani/cdi-nested
>
> MyResource is a JAX-RS service into MyService is @Injected
> MyDao is in-turn @Injected into MyService. When I run it (in TomEE
> 1.6.0.1), MyDao is null inside the MyService instance injected to
> MyResource. What do I need to do to make it work or is there another way
> of doing this (short of explicitly instantiating objects).
Re: @Injected field of a @Injected field is null
Posted by Romain Manni-Bucau <rm...@gmail.com>.
works great on trunk.
side note: bean instantiation is not done while ejb *business* method is
not called for ejb and any method for cdi beans
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau
2014-06-04 3:49 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
> I put together a small sample app here:
> https://github.com/lakamsani/cdi-nested
>
> MyResource is a JAX-RS service into MyService is @Injected
> MyDao is in-turn @Injected into MyService. When I run it (in TomEE
> 1.6.0.1), MyDao is null inside the MyService instance injected to
> MyResource. What do I need to do to make it work or is there another way
> of doing this (short of explicitly instantiating objects).