[JBoss Portal] - Re: Hibernate Open Session In View (in Portlet)
by EricML
The problem is, that you have an open session in the doView()-Method of the GenericPortlet. However, The strange thing is that the session is open as well in the jsp as my latest investigations have shown.
These are the last lines of the doView-Method:
| rResponse.setContentType("text/html");
| PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/test/test.jsp");
| prd.include(rRequest, rResponse);
|
The session is open before and after the call to prd.include(rRequest, rResponse);. It is open as well in the JSP (I have put the session into the httpsession and retrieved it in the jsp). I can even reattach objects to that session in the JSP and work with the lazy objects. If I dont reattach the objects the mentioned Lazy Initialization Exception (no session or session is closed) will be thrown.
The question is: why do I have to reattach the objects although the session has not been closed?
Keeping an closer eye on the "lazy" object I found out that the PersistentMap from Hibernate which is used instead of the "normal" collection has the session-attribute set to null. Is there anyone who can explain at which point this happened or how i can prevent this from happening?
Maybe this has something to do with the bound JTA-Transaction?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4141263#4141263
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4141263
18 years
[EJB 3.0] - Re: Bug: Injected EJB objects instantiated on every MDB call
by wolfc
"ariekenb" wrote : After doing this I only see 2 instances of my stateless session bean created, even in tests where it's called from multiple different MDBs and directly from clients. It appears StrictMaxPool is much more conservative in ThreadlocalPool.
|
| doktora - Maybe using StrictMaxPool would be an interesting test/workaround in your case?
|
| To the JBoss experts out there - is it a "problem" that ThreadlocalPool appears to create a new instance of a stateless session bean for every call from an MDB, or is this somehow being managed? What exactly is the difference with StrictMaxPool? Will using StrictMaxPool kill performance?
http://jira.jboss.org/jira/browse/JBAS-5345
ThreadlocalPool should be used in a scenario where there is high concurrency on an EJB which is being called by a ThreadPool. The ThreadlocalPool will then ensure that there is one instance per Thread and no contention between these threads.
It would appear that JBossMQ does not use a ThreadPool, but instantiates threads on the fly. Thus the ThreadlocalPool will keep on creating instances to match.
That makes the use of StrictMaxPool mandatory.
Thus only remains the issue of why ThreadlocalPool retains instances after the thread has died. ThreadlocalPool retains all instances to make sure PreDestroy is called upon destruction of the pool.
I could implement something that PreDestroy is called when the instance is ready for GC, but in this scenario it would entail creating an instance for each MDB call. That is certainly a higher performance hit then contention in the StrictMaxPool.
http://jira.jboss.org/jira/browse/JBAS-1175
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4141227#4141227
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4141227
18 years