+1 to any/all David Blevin's responses...and of course, the same for all of Romain's responses as well!
Just to share... I remember I used to see a bunch of LOCK exceptions in server log with @Singleton after David advised me to use @Singleton, but I kept tuning the implementation. Now, I have not seen those exceptions any more in server log. I don't know if it was just a TomEE 1.5.1 bug that got fixed in 1.5.2-SNAPSHOT, but recently, I decreased the # of minutes on the @Schedule method defined on the only 2 @Singleton beans I have, and still, it is performing (very) well and no exceptions in server log. I know this may be a bit unrelated, but still thought I might share. I'm hoping to add more @Singleton for @Schedule tasks. My code has been working well with @Stateless for the design, which is evident when web application code is generated by NetBeans from database schema. Entity bean > @Stateless EJB for the entity bean > JSF managed bean which references @Stateless EJB and entity bean > xhtml page, which references the JSF managed bean Of course, I have done refactoring to meet requirements. :) This design/implementation has worked for me, in production, while the app was running on Glassfish 3.1+ and now with TomEE. On Thu, Mar 7, 2013 at 7:10 PM, David Blevins <[email protected]>wrote: > I'd also recommend @Singleton in conjunction with @Lock(READ). > > The @Stateless bean type is good when you explicitly need to limit the > number of instances/concurrent calls. If this sort of limiting is not a > critical part of the design, then likely @Stateless was used because this > is the bean type people tend to use by default. > > Really, @Singleton with @Lock(READ) should be used by default and other > bean types used only when there is a specific design goal you need to > achieve. > > > -David > > On Mar 6, 2013, at 10:19 AM, Romain Manni-Bucau <[email protected]> > wrote: > > > In very very heavy load and for a simple app it can be as much as your > http > > request thread pool size (200 by default) > > > > Note: using @Singleton can help too if you can > > Le 6 mars 2013 18:51, "José Luis Cetina" <[email protected]> a écrit > : > > > >> Really im not sure how many users the webapp could handle, because is a > >> public webapp, i will increase the MaxSize to 50 or 100, but for any > >> "unexpected > >> overload" i will let StrictPooling to false. > >> > >> Do you consider its to much to increase to 50/100 to maxsize?? > >> > >> > >> > >> 2013/3/6 Jean-Louis MONTEIRO <[email protected]> > >> > >>> José, > >>> > >>> The MinSize is not the problem IMO. > >>> The MaxSize is definitely the issue. Do you have more than 10 (default > >>> value) simultaneous users? > >>> > >>> The StrictPooling is great to be able to always answer in case of small > >>> over load. > >>> But, you have to know that after being used, instances will be removed > >> and > >>> garbage collected. > >>> > >>> Also, creating instances can be consuming depending on the bean. > >>> > >>> I would recommend not only to set it to true, but before, trying to > >> define > >>> as much as possible the correct value for MaxSize depending on your > SLAs. > >>> > >>> Hope it helps > >>> JLouis > >>> > >>> > >>> > >>> > >>> 2013/3/6 José Luis Cetina <[email protected]> > >>> > >>>> Im using 1.6.0-SNAPSHOT. > >>>> > >>>> I will change > >>>> > >>>> StrictPooling = true ==> false > >>>> MinSize = 0 ==> 2 > >>>> > >>>> In stateless section and let you know. > >>>> > >>>> > >>>> > >>>> 2013/3/6 Howard W. Smith, Jr. <[email protected]> > >>>> > >>>>> José, > >>>>> > >>>>> I'm sure the others will ask, are you seeing this with tomee 1.5.2 or > >>>> 1.6.0 > >>>>> snapshot? or only seeing on your production server running tomee > >> 1.5.1 > >>>> or > >>>>> 1.5.2 / 1.6.0 snapshot? > >>>>> > >>>>> Wow, Jean-Louis beat me to it...asking for the TOMEE version. :) > >>>>> > >>>>> Also, i searched google for the following: > >>>>> > >>>>> No instances available in Stateless Session Bean pool > >>>>> > >>>>> and found the following (which is definitely related to Jean-Louis > >>>>> response): > >>>>> > >>>>> [1] > >>>>> > >>>>> > >>>> > >>> > >> > http://apache-geronimo.328035.n3.nabble.com/jira-Created-GERONIMO-5455-quot-No-instances-available-in-Stateless-Session-Bean-pool-quot-error-wher-td978236.html > >>>>> > >>>>> [2] > >>>>> > >>>>> > >>>> > >>> > >> > http://openejb.979440.n4.nabble.com/Query-Regarding-Stateless-Session-Bean-Instance-Pool-Configuration-td980239.html > >>>>> > >>>>> [3] http://docs.oracle.com/cd/E15051_01/wls/docs103/ejb/session.html > >>>>> > >>>>> > >>>>> Howard > >>>>> > >>>>> > >>>>> On Wed, Mar 6, 2013 at 10:46 AM, José Luis Cetina < > >>> [email protected] > >>>>>> wrote: > >>>>> > >>>>>> Hi im gettin *ConcurrentAccessTimeoutException: No instances > >>> available > >>>> in > >>>>>> Stateless Session Bean pool. Waited 30 SECONDS....* > >>>>>> > >>>>>> Here is the complete log: http://pastebin.ca/2328770 > >>>>>> > >>>>>> Any advice, what could be? Do i have to configure something in > >>>>> tomee.xml?? > >>>>>> > >>>>>> Part of the log: > >>>>>> > >>>>>> > >>>>>> *Mar 05, 2013 9:38:20 PM > >> org.apache.openejb.cdi.CdiAppContextsService > >>>>>> lazyStartSessionContext > >>>>>> WARNING: Could NOT lazily initialize session context because of > >> null > >>>>>> RequestContext > >>>>>> javax.ejb.ConcurrentAccessTimeoutException: No instances available > >> in > >>>>>> Stateless Session Bean pool. Waited 30 SECONDS > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.openejb.core.stateless.StatelessInstanceManager.getInstance(StatelessInstanceManager.java:190) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:186) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:256) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:251) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:85) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:279) > >>>>>> at sun.proxy.$Proxy245.getExamenAplicado(Unknown Source) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > com.grupokx.preparatorianos.controller.examendiagnostico.ExamenDiagnosticoMBean.mypostconstruct(ExamenDiagnosticoMBean.java:63) > >>>>>> at sun.reflect.GeneratedMethodAccessor800.invoke(Unknown Source) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > >>>>>> at java.lang.reflect.Method.invoke(Method.java:601) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.tomee.catalina.JavaeeInstanceManager.postConstruct(JavaeeInstanceManager.java:132) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.tomee.catalina.JavaeeInstanceManager.newInstance(JavaeeInstanceManager.java:69) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.config.annotation.Tomcat7AnnotationLifecycleProvider.postConstruct(Tomcat7AnnotationLifecycleProvider.java:94) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:213) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.createManagedBean(ManagedBeanResolver.java:333) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.getValue(ManagedBeanResolver.java:296) > >>>>>> at > >> javax.el.CompositeELResolver.getValue(CompositeELResolver.java:58) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:179) > >>>>>> at > >> org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72) > >>>>>> at org.apache.el.parser.AstValue.getValue(AstValue.java:161) > >>>>>> at org.apache.el.parser.AstEqual.getValue(AstEqual.java:38) > >>>>>> at > >>>>> > >>> > org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.webbeans.el.WrappedValueExpression.getValue(WrappedValueExpression.java:68) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:96) > >>>>>> at > >>>>> > >>> > javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:266) > >>>>>> at > >>>>>> > >>>>> > >>>> > >>> > >> > javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:1187) > >>>>>> at > >>>>>> > >>>> > >> > javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:494) > >>>>>> at > >>>>>> > >>>> > >> > javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541) > >>>>>> at > >>>>>> > >>>> > >> > javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541) > >>>>>> at > >>>>>> > >>>> > >> > javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1981) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:116) > >>>>>> at > >>>>>> > >>>> > >> > org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241) > >>>>>> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) > >>>>>> at > >>> org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:45) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) > >>>>>> at > >>>>>> > >>>> > >> > org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) > >>>>>> at > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) > >>>>>> at > >> org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > >>>>>> at > >>>>>> > >>>>>> > >>>>> > >>>> > >>> > >> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > >>>>>> at java.lang.Thread.run(Thread.java:722) > >>>>>> * > >>>>>> > >>>>> > >>>> > >>>> > >>>> > >>>> -- > >>>> ------------------------------------------------------------------- > >>>> *SCJA. José Luis Cetina* > >>>> ------------------------------------------------------------------- > >>>> > >>> > >>> > >>> > >>> -- > >>> Jean-Louis > >>> > >> > >> > >> > >> -- > >> ------------------------------------------------------------------- > >> *SCJA. José Luis Cetina* > >> ------------------------------------------------------------------- > >> > >
