You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "Howard W. Smith, Jr." <sm...@gmail.com> on 2013/03/10 12:47:45 UTC

Re: TomEE undeploy app is not invoking @PreDestroy on CDI @ApplicationScoped bean

Romain, update/FYI/question on this old topic...

1. @PreDestroy, on CDI @ApplicationScoped bean, is executed, whenever I
shutdown TomEE.
2. I don't undeploy apps much anymore, I shutdown TomEE, drop new WAR, and
remove/delete the folder that previous WAR was unpacked in/to.

3. Here is the kicker... when I approached you about this in the past, I
only had 1 CDI @ApplicationScoped bean, and it is working great in
production. Recently, I added another CDI @ApplicationScoped bean, and for
whatever reason, @PreDestroy is 'only' executed on the 1st/original CDI
@ApplicationScoped bean, but not on the 2nd CDI @ApplicationScopedBean.

4. So, recently, I added CDI @ApplicationScoped bean,
ApplicationMessageBean (for JMS/ActiveMQ)

5. I added @PreDestroy to CDI @ApplicationScoped bean,
ApplicationMessageBean, and shutdown TomEE does not invoke the @PreDestroy
method

6. Originally, i only had (and still have) CDI @ApplicationScoped
ApplicationScopeBean; @PreDestroy is always triggered on this bean, when I
shutdown TomEE.



On Sat, Nov 24, 2012 at 11:44 PM, Howard W. Smith, Jr. <
smithh032772@gmail.com> wrote:

> Romain, i'm seeing @PreDestroy executed now, but honestly, I think I see
> it executing sometimes. Sometimes, I don't see it execute, but I'll try to
> watch more closely to see if @PreDestroy (on CDI @ApplicatonScoped) is
> executing every time. :)
>
> Thanks!
>
>

Re: TomEE undeploy app is not invoking @PreDestroy on CDI @ApplicationScoped bean

Posted by Romain Manni-Bucau <rm...@gmail.com>.
the dispose type is not the produce one, is it normal?

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/3/11 mauro <na...@gmail.com>

> if I move the code of the method annotated @ PreDestroy in the method
> @Disposes  of cdi?????
>
> for example for create a object @ApplicationScoped with cdi , i use a
> method
> @Produces.
> And for destuct it i use the method @Disposes.
>
> When the application destruct the beans @Applicationscoped , the mehod with
> the parameter @Disposes it is callled automatically .
>
> i write a example of a method producer and a method that @Disposes the bean
> .
>
>
>
>
> @Produces @ManagerQueque @ApplicationScoped
>             public QueueSession createOrderSession(@Order QueueConnection
> conn)
> throws JMSException {
>                 return conn.createQueueSession(true,
> Session.AUTO_ACKNOWLEDGE);
>             }
>
>             public void closeOrderSession(@Disposes @ManagerQueque
> QueueConnection
> conn) throws JMSException {
>                 conn.close();
>             }
>
>
> you think that it is ok ?
> mauro
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/TomEE-undeploy-app-is-not-invoking-PreDestroy-on-CDI-ApplicationScoped-bean-tp4658744p4661403.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: TomEE undeploy app is not invoking @PreDestroy on CDI @ApplicationScoped bean

Posted by mauro <na...@gmail.com>.
if I move the code of the method annotated @ PreDestroy in the method
@Disposes  of cdi?????

for example for create a object @ApplicationScoped with cdi , i use a method
@Produces.
And for destuct it i use the method @Disposes.

When the application destruct the beans @Applicationscoped , the mehod with
the parameter @Disposes it is callled automatically .

i write a example of a method producer and a method that @Disposes the bean
.




@Produces @ManagerQueque @ApplicationScoped 
	    public QueueSession createOrderSession(@Order QueueConnection conn)
throws JMSException {
	        return conn.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
	    }
	 
	    public void closeOrderSession(@Disposes @ManagerQueque QueueConnection
conn) throws JMSException {
	        conn.close();
	    }


you think that it is ok ? 
mauro



--
View this message in context: http://openejb.979440.n4.nabble.com/TomEE-undeploy-app-is-not-invoking-PreDestroy-on-CDI-ApplicationScoped-bean-tp4658744p4661403.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: TomEE undeploy app is not invoking @PreDestroy on CDI @ApplicationScoped bean

Posted by Mark Struberg <st...@yahoo.de>.

And please make sure that it's really a CDI @ApplicationScoped and not the one from JSF.


LieGrue,
strub




>________________________________
> From: Romain Manni-Bucau <rm...@gmail.com>
>To: users@tomee.apache.org 
>Sent: Sunday, March 10, 2013 1:08 PM
>Subject: Re: TomEE undeploy app is not invoking @PreDestroy on CDI @ApplicationScoped bean
> 
>As usual if you reproduce it we can have a look if thats a bug or not ;)
>Le 10 mars 2013 12:50, "Howard W. Smith, Jr." <sm...@gmail.com> a
>écrit :
>
>> More on this (forgot to tell you)...
>>
>> ApplicationMessageBean is a property of ApplicationScopeBean, while
>> ApplicationScopeBean is property to CDI @SessionScoped beans and servlet
>> filter.
>>
>> Maybe this has something to do with it. :)
>>
>>
>>
>> On Sun, Mar 10, 2013 at 7:47 AM, Howard W. Smith, Jr. <
>> smithh032772@gmail.com> wrote:
>>
>> > Romain, update/FYI/question on this old topic...
>> >
>> > 1. @PreDestroy, on CDI @ApplicationScoped bean, is executed, whenever I
>> > shutdown TomEE.
>> > 2. I don't undeploy apps much anymore, I shutdown TomEE, drop new WAR,
>> and
>> > remove/delete the folder that previous WAR was unpacked in/to.
>> >
>> > 3. Here is the kicker... when I approached you about this in the past, I
>> > only had 1 CDI @ApplicationScoped bean, and it is working great in
>> > production. Recently, I added another CDI @ApplicationScoped bean, and
>> for
>> > whatever reason, @PreDestroy is 'only' executed on the 1st/original CDI
>> > @ApplicationScoped bean, but not on the 2nd CDI @ApplicationScopedBean.
>> >
>> > 4. So, recently, I added CDI @ApplicationScoped bean,
>> > ApplicationMessageBean (for JMS/ActiveMQ)
>> >
>> > 5. I added @PreDestroy to CDI @ApplicationScoped bean,
>> > ApplicationMessageBean, and shutdown TomEE does not invoke the
>> @PreDestroy
>> > method
>> >
>> > 6. Originally, i only had (and still have) CDI @ApplicationScoped
>> > ApplicationScopeBean; @PreDestroy is always triggered on this bean, when
>> I
>> > shutdown TomEE.
>> >
>> >
>> >
>> > On Sat, Nov 24, 2012 at 11:44 PM, Howard W. Smith, Jr. <
>> > smithh032772@gmail.com> wrote:
>> >
>> >> Romain, i'm seeing @PreDestroy executed now, but honestly, I think I see
>> >> it executing sometimes. Sometimes, I don't see it execute, but I'll try
>> to
>> >> watch more closely to see if @PreDestroy (on CDI @ApplicatonScoped) is
>> >> executing every time. :)
>> >>
>> >> Thanks!
>> >>
>> >>
>>
>
>
>

Re: TomEE undeploy app is not invoking @PreDestroy on CDI @ApplicationScoped bean

Posted by Romain Manni-Bucau <rm...@gmail.com>.
As usual if you reproduce it we can have a look if thats a bug or not ;)
Le 10 mars 2013 12:50, "Howard W. Smith, Jr." <sm...@gmail.com> a
écrit :

> More on this (forgot to tell you)...
>
> ApplicationMessageBean is a property of ApplicationScopeBean, while
> ApplicationScopeBean is property to CDI @SessionScoped beans and servlet
> filter.
>
> Maybe this has something to do with it. :)
>
>
>
> On Sun, Mar 10, 2013 at 7:47 AM, Howard W. Smith, Jr. <
> smithh032772@gmail.com> wrote:
>
> > Romain, update/FYI/question on this old topic...
> >
> > 1. @PreDestroy, on CDI @ApplicationScoped bean, is executed, whenever I
> > shutdown TomEE.
> > 2. I don't undeploy apps much anymore, I shutdown TomEE, drop new WAR,
> and
> > remove/delete the folder that previous WAR was unpacked in/to.
> >
> > 3. Here is the kicker... when I approached you about this in the past, I
> > only had 1 CDI @ApplicationScoped bean, and it is working great in
> > production. Recently, I added another CDI @ApplicationScoped bean, and
> for
> > whatever reason, @PreDestroy is 'only' executed on the 1st/original CDI
> > @ApplicationScoped bean, but not on the 2nd CDI @ApplicationScopedBean.
> >
> > 4. So, recently, I added CDI @ApplicationScoped bean,
> > ApplicationMessageBean (for JMS/ActiveMQ)
> >
> > 5. I added @PreDestroy to CDI @ApplicationScoped bean,
> > ApplicationMessageBean, and shutdown TomEE does not invoke the
> @PreDestroy
> > method
> >
> > 6. Originally, i only had (and still have) CDI @ApplicationScoped
> > ApplicationScopeBean; @PreDestroy is always triggered on this bean, when
> I
> > shutdown TomEE.
> >
> >
> >
> > On Sat, Nov 24, 2012 at 11:44 PM, Howard W. Smith, Jr. <
> > smithh032772@gmail.com> wrote:
> >
> >> Romain, i'm seeing @PreDestroy executed now, but honestly, I think I see
> >> it executing sometimes. Sometimes, I don't see it execute, but I'll try
> to
> >> watch more closely to see if @PreDestroy (on CDI @ApplicatonScoped) is
> >> executing every time. :)
> >>
> >> Thanks!
> >>
> >>
>

Re: TomEE undeploy app is not invoking @PreDestroy on CDI @ApplicationScoped bean

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
More on this (forgot to tell you)...

ApplicationMessageBean is a property of ApplicationScopeBean, while
ApplicationScopeBean is property to CDI @SessionScoped beans and servlet
filter.

Maybe this has something to do with it. :)



On Sun, Mar 10, 2013 at 7:47 AM, Howard W. Smith, Jr. <
smithh032772@gmail.com> wrote:

> Romain, update/FYI/question on this old topic...
>
> 1. @PreDestroy, on CDI @ApplicationScoped bean, is executed, whenever I
> shutdown TomEE.
> 2. I don't undeploy apps much anymore, I shutdown TomEE, drop new WAR, and
> remove/delete the folder that previous WAR was unpacked in/to.
>
> 3. Here is the kicker... when I approached you about this in the past, I
> only had 1 CDI @ApplicationScoped bean, and it is working great in
> production. Recently, I added another CDI @ApplicationScoped bean, and for
> whatever reason, @PreDestroy is 'only' executed on the 1st/original CDI
> @ApplicationScoped bean, but not on the 2nd CDI @ApplicationScopedBean.
>
> 4. So, recently, I added CDI @ApplicationScoped bean,
> ApplicationMessageBean (for JMS/ActiveMQ)
>
> 5. I added @PreDestroy to CDI @ApplicationScoped bean,
> ApplicationMessageBean, and shutdown TomEE does not invoke the @PreDestroy
> method
>
> 6. Originally, i only had (and still have) CDI @ApplicationScoped
> ApplicationScopeBean; @PreDestroy is always triggered on this bean, when I
> shutdown TomEE.
>
>
>
> On Sat, Nov 24, 2012 at 11:44 PM, Howard W. Smith, Jr. <
> smithh032772@gmail.com> wrote:
>
>> Romain, i'm seeing @PreDestroy executed now, but honestly, I think I see
>> it executing sometimes. Sometimes, I don't see it execute, but I'll try to
>> watch more closely to see if @PreDestroy (on CDI @ApplicatonScoped) is
>> executing every time. :)
>>
>> Thanks!
>>
>>