This content has been marked as final.
Show 7 replies
-
1. Re: persistence-context-ref always yields same object instan
jaikiran Aug 18, 2009 1:19 AM (in response to henk53)Whether I do the JNDI lookup multiple times right after each other in the same method, or test what the JNDI lookup returns in multiple simultaneous requests, the result is always an object instance with the same ID (e.g. org.jboss.jpa.tx.TransactionScopedEntityManager@d78f1b).
Hmm, i would have expected it to return different instances in the multiple simultaneous requests usecase. -
2. Re: persistence-context-ref always yields same object instan
henk53 Aug 18, 2009 7:21 AM (in response to henk53)"jaikiran" wrote:
Whether I do the JNDI lookup multiple times right after each other in the same method, or test what the JNDI lookup returns in multiple simultaneous requests, the result is always an object instance with the same ID (e.g. org.jboss.jpa.tx.TransactionScopedEntityManager@d78f1b).
Hmm, i would have expected it to return different instances in the multiple simultaneous requests usecase.
Me too. What I more precisely did was the following simple test:
1) Put the simple above shown code in a ServletFilter I happened to have on my screen that requested the EM out of JNDI.
2) Added a break-point to it, requested a page being filtered, inspected the identity of the instance using the Eclipse debugger.
3) While the request thread was still being suspended, I did a new request (for the same page) in a second tab of the same browser.
4) Observed the break-point was being hit again, but now in another thread and confirmed that the identity of the instance was the same one as was returned for the currently suspended thread.
If there is anything else you'd like me to test, please let me know. -
3. Re: persistence-context-ref always yields same object instan
jaikiran Aug 19, 2009 11:12 AM (in response to henk53)If there is anything else you'd like me to test, please let me know.
The information you provided should be enough to reproduce this locally. I'll look into this and read a bit more in the spec before updating this thread later this week. -
4. Re: persistence-context-ref always yields same object instan
jaikiran Aug 23, 2009 10:04 AM (in response to henk53)Looking into the way this is handled, this appears to be an issue with the web layer where the ENC injections happen only once (during the start). Effectively, the EntityManager is injected once into the ENC of that component. The spec says:
In general, lookups of objects in the JNDI java: namespace are required to return a new instance of the requested object every time. Exceptions are allowed for the following:
The container knows the object is immutable (for example, objects of type java.lang.String), or knows that the application cannot change the state of the object.
The object is defined to be a singleton, such that only one instance of the object may exist in the JVM.
The name used for the lookup is defined to return an instance of the object that might be shared. The name java:comp/ORB is such a name.
So this looks like a bug to me. Could you please create an issue in JBAS here https://jira.jboss.org/jira/browse/JBAS -
5. Re: persistence-context-ref always yields same object instan
henk53 Aug 24, 2009 6:07 PM (in response to henk53)"jaikiran" wrote:
Looking into the way this is handled, this appears to be an issue with the web layer where the ENC injections happen only once (during the start). Effectively, the EntityManager is injected once into the ENC of that component. The spec says:In general, lookups of objects in the JNDI java: namespace are required to return a new instance of the requested object every time. Exceptions are allowed for the following:
The container knows the object is immutable (for example, objects of type java.lang.String), or knows that the application cannot change the state of the object.
The object is defined to be a singleton, such that only one instance of the object may exist in the JVM.
The name used for the lookup is defined to return an instance of the object that might be shared. The name java:comp/ORB is such a name.
So this looks like a bug to me. Could you please create an issue in JBAS here https://jira.jboss.org/jira/browse/JBAS
Sure, no problem. Thanks for verifying. -
6. Re: persistence-context-ref always yields same object instan
henk53 Aug 30, 2009 5:07 PM (in response to henk53)For reference, the JIRA issue was created here: https://jira.jboss.org/jira/browse/JBAS-7218
-
7. Re: persistence-context-ref always yields same object instan
henk53 Aug 30, 2009 5:08 PM (in response to henk53)"henk53" wrote:
For reference, the JIRA issue was created here: https://jira.jboss.org/jira/browse/JBAS-7218
For the lazy people, the clickable version:
https://jira.jboss.org/jira/browse/JBAS-7218