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 2012/12/15 08:10:54 UTC

TomEE @Stateless EJB not closing javamail connections

I 'had' the following in my web app:

@Stateless with @Schedule that will create/instantiate new javamail
session, store, and get folder and messages; @Schedule was set for every 2
minutes

When I shutdown TomEE, I see the exception below; look closely, and you
will see EmailStatelessBean is the cause of the infamous Javamail
exception, too many simultaneous connections. This is an FYI. I tightened
up my code a little...to workaround this issue... i keep javamail store
open/connected and only close and reopen/connect when error occurs.



Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled
in the future
urce)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
at
org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:176)
at
org.apache.openejb.monitoring.StatsInterceptor.AroundTimeout(StatsInterceptor.java:140)
at sun.reflect.GeneratedMethodAccessor538.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
at
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:138)
at
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:237)
at
org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:189)
at
org.apache.openejb.core.timer.EjbTimerServiceImpl.ejbTimeout(EjbTimerServiceImpl.java:569)
at
org.apache.openejb.core.timer.EjbTimeoutJob.execute(EjbTimeoutJob.java:39)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
javax.mail.AuthenticationFailedException: [ALERT] Too many simultaneous
connections. (Failure)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:660)
at javax.mail.Service.connect(Service.java:295)
at javax.mail.Service.connect(Service.java:176)
at utils.mail.EmailHandler.initialize(EmailHandler.java:65)
at
utils.mail.EmailStatelessBean.checkEmailsDeleteAndNotify(EmailStatelessBean.java:81)
at sun.reflect.GeneratedMethodAccessor539.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
at org.apache.openejb.cdi.CdiInterceptor.invoke(CdiInterceptor.java:128)
at org.apache.openejb.cdi.CdiInterceptor.access$000(CdiInterceptor.java:43)
at org.apache.openejb.cdi.CdiInterceptor$1.call(CdiInterceptor.java:64)
at
org.apache.openejb.cdi.CdiInterceptor.aroundInvoke(CdiInterceptor.java:70)
at sun.reflect.GeneratedMethodAccessor118.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
at
org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:176)
at
org.apache.openejb.monitoring.StatsInterceptor.AroundTimeout(StatsInterceptor.java:140)
at sun.reflect.GeneratedMethodAccessor538.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
at
org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
at
org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:138)
at
org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:237)
at
org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:189)
at
org.apache.openejb.core.timer.EjbTimerServiceImpl.ejbTimeout(EjbTimerServiceImpl.java:569)
at
org.apache.openejb.core.timer.EjbTimeoutJob.execute(EjbTimeoutJob.java:39)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Re: TomEE @Stateless EJB not closing javamail connections

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Maybe share some code and your conf...
Le 15 déc. 2012 19:09, "Howard W. Smith, Jr." <sm...@gmail.com> a
écrit :

> I have 'defaultInstance' which uses 'transport' for SMTP (sendmail).
>
> I use 'getInstance' with/for imap, and imap uses 'store' instead of
> transport, per my understanding/code.
>
> I was closing the store after connecting to store...every time @Schedule is
> executed, but I changed the implementation last night...to avoid this too
> many simultaneous connections. i only initialize/reconnect to the imap
> 'store', when/if error occurs with one of the javamail operations that I'm
> using in the app.
>
> 'on demand' approach. :)
>
> I just wanted to report this...maybe I just don't know how to use
> @Stateless, but I'm recognizing a lot of exceptions while attempting to use
> @Stateless for new/various operations in the app. I see why David Blevins
> recommended to use singleton and @Schedule together...to avoid overlapping
> executions.
>
> Even with @Schedule and Singleton, I'm seeing some exceptions in the log...
> only when endusers wake up and starting to use the web app. I had @Schedule
> executing every 2 minutes. I think when enduser(s) in the web app, their
> http/jsf requests are postponing singleton @Schedule, and ejbtimer raises
> exceptions...while endusers doing their thing. :)
>
>
> On Sat, Dec 15, 2012 at 1:00 PM, Romain Manni-Bucau
> <rm...@gmail.com>wrote:
>
> > do you close the transport?
>

Re: TomEE @Stateless EJB not closing javamail connections

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
I have 'defaultInstance' which uses 'transport' for SMTP (sendmail).

I use 'getInstance' with/for imap, and imap uses 'store' instead of
transport, per my understanding/code.

I was closing the store after connecting to store...every time @Schedule is
executed, but I changed the implementation last night...to avoid this too
many simultaneous connections. i only initialize/reconnect to the imap
'store', when/if error occurs with one of the javamail operations that I'm
using in the app.

'on demand' approach. :)

I just wanted to report this...maybe I just don't know how to use
@Stateless, but I'm recognizing a lot of exceptions while attempting to use
@Stateless for new/various operations in the app. I see why David Blevins
recommended to use singleton and @Schedule together...to avoid overlapping
executions.

Even with @Schedule and Singleton, I'm seeing some exceptions in the log...
only when endusers wake up and starting to use the web app. I had @Schedule
executing every 2 minutes. I think when enduser(s) in the web app, their
http/jsf requests are postponing singleton @Schedule, and ejbtimer raises
exceptions...while endusers doing their thing. :)


On Sat, Dec 15, 2012 at 1:00 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:

> do you close the transport?

Re: TomEE @Stateless EJB not closing javamail connections

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hey,

do you close the transport?



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



2012/12/15 Howard W. Smith, Jr. <sm...@gmail.com>:
> I 'had' the following in my web app:
>
> @Stateless with @Schedule that will create/instantiate new javamail
> session, store, and get folder and messages; @Schedule was set for every 2
> minutes
>
> When I shutdown TomEE, I see the exception below; look closely, and you
> will see EmailStatelessBean is the cause of the infamous Javamail
> exception, too many simultaneous connections. This is an FYI. I tightened
> up my code a little...to workaround this issue... i keep javamail store
> open/connected and only close and reopen/connect when error occurs.
>
>
>
> Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled
> in the future
> urce)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
> at
> org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:176)
> at
> org.apache.openejb.monitoring.StatsInterceptor.AroundTimeout(StatsInterceptor.java:140)
> at sun.reflect.GeneratedMethodAccessor538.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
> at
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:138)
> at
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:237)
> at
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:189)
> at
> org.apache.openejb.core.timer.EjbTimerServiceImpl.ejbTimeout(EjbTimerServiceImpl.java:569)
> at
> org.apache.openejb.core.timer.EjbTimeoutJob.execute(EjbTimeoutJob.java:39)
> at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
> javax.mail.AuthenticationFailedException: [ALERT] Too many simultaneous
> connections. (Failure)
> at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:660)
> at javax.mail.Service.connect(Service.java:295)
> at javax.mail.Service.connect(Service.java:176)
> at utils.mail.EmailHandler.initialize(EmailHandler.java:65)
> at
> utils.mail.EmailStatelessBean.checkEmailsDeleteAndNotify(EmailStatelessBean.java:81)
> at sun.reflect.GeneratedMethodAccessor539.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
> at org.apache.openejb.cdi.CdiInterceptor.invoke(CdiInterceptor.java:128)
> at org.apache.openejb.cdi.CdiInterceptor.access$000(CdiInterceptor.java:43)
> at org.apache.openejb.cdi.CdiInterceptor$1.call(CdiInterceptor.java:64)
> at
> org.apache.openejb.cdi.CdiInterceptor.aroundInvoke(CdiInterceptor.java:70)
> at sun.reflect.GeneratedMethodAccessor118.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
> at
> org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:176)
> at
> org.apache.openejb.monitoring.StatsInterceptor.AroundTimeout(StatsInterceptor.java:140)
> at sun.reflect.GeneratedMethodAccessor538.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181)
> at
> org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163)
> at
> org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:138)
> at
> org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:237)
> at
> org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:189)
> at
> org.apache.openejb.core.timer.EjbTimerServiceImpl.ejbTimeout(EjbTimerServiceImpl.java:569)
> at
> org.apache.openejb.core.timer.EjbTimeoutJob.execute(EjbTimeoutJob.java:39)
> at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)