Re: EntityManager Propagation Problem under 3.1

2009-01-28 Thread David Blevins

Hi Jim,

I finally got to the bottom of the issue.  There definitely was a bug,  
but it was in OpenEJB 3.0.  We must have inadvertently fixed it when  
we did the stateful container rework between 3.0 and 3.1.


It took me a while to notice this because of all the parent/child  
names in the sample, but it turns out your stateful session beans are  
syblings as they are created like so:



  ParentLocal parent = context.lookup("ParentBeanLocal");
  ChildLocal child = context.lookup("ChildBeanLocal");

In order for the "ChildBean" stateful session bean to really be a  
child it must be created by the ParentBean.  Meaning ParentBean must  
be the one to lookup the ChildBean or have it injected via @EJB.   
Here's a relevant JPA spec quote:


5.6.2.1 Inheritance of Extended Persistence Context

If a stateful session bean instantiates a stateful session
bean which also has such an extended persistence context, the
extended persistence context of the first stateful session
bean is inherited by the second stateful session bean and
bound to it, and this rule recursively applies --
independently of whether transactions are active or not at
the point of the creation of the stateful session beans.

If the persistence context has been inherited by any stateful
session beans, the container does not close the persistence
context until all such stateful session beans have been
removed or otherwise destroyed.

If you add an "@EJB ChildLocal child" ref inside ParentBean and update  
your test code to not lookup the ChildBean and instead get it from the  
ParentBean, than all the tests pass as expected.


Not sure what kind of leak we had in the 3.0 release that allowed non- 
child beans to mess with the persistence context of another stateful  
bean -- sort of a double bug as it also means two unrelated stateful  
beans wouldn't be allowed to have their own private extended  
persistence contexts -- but I'm certainly glad it's gone.


Note that if you rely critically on this "bug" we could add it in as a  
feature.  I use bug in quotes because tracking the persistence context  
by the thread as if it were in a transaction and regardless if  
stateful inheritance could be a useful technique.  One might think of  
it as a new kind of persistence context management that has yet to  
make the spec.


-David


On Jan 27, 2009, at 8:01 PM, David Blevins wrote:


Hi Jim,

Wanted to give you an update.  I've been looking into this one and  
so far haven't been able to find the source of the issue.  In  
addition to your sample I've been adding more tests in this area --  
the java ee tck has plenty but it's nice to have some of our own.


Seems the basic functionality of extended persistence contexts is  
working:


http://svn.apache.org/repos/asf/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/EntityManagerPropogationTest.java

I'm going to keep working with your sample, but if you wanted to  
help expand that test case that could be very useful.  You did some  
good work in the sample app.


-David


On Dec 10, 2008, at 9:33 AM, David Blevins wrote:



On Nov 21, 2008, at 3:04 PM, JimOR wrote:


David,

Looks like OpenEJB3.1 is the culprit.  EJB3.0 with JPA 1.0.1, 1.1,  
1.2 and
1.3-SNAPSHOT work as expected, but 3.1 with any of the JPA jars  
fails.


This sample  http://www.nabble.com/file/p20631026/sample.zip  
sample.zip
should give you a head start recreating the scenario.  I had to  
remove the
OpenJPA jars to fit within the file upload size limit, drop them  
into

sample/lib and you should be good to go.

The sample/test folder contains the junit xml results of the test  
case under

the various classpaths.


FYI, filled a JIRA for this:

https://issues.apache.org/jira/browse/OPENEJB-970
(notifications:  
https://issues.apache.org/jira/secure/ViewIssue.jspa?id=12410384&watch=true)

Thanks for putting that sample together!

-David









Re: EntityManager Propagation Problem under 3.1

2009-01-27 Thread David Blevins

Hi Jim,

Wanted to give you an update.  I've been looking into this one and so  
far haven't been able to find the source of the issue.  In addition to  
your sample I've been adding more tests in this area -- the java ee  
tck has plenty but it's nice to have some of our own.


Seems the basic functionality of extended persistence contexts is  
working:


http://svn.apache.org/repos/asf/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/EntityManagerPropogationTest.java

I'm going to keep working with your sample, but if you wanted to help  
expand that test case that could be very useful.  You did some good  
work in the sample app.


-David


On Dec 10, 2008, at 9:33 AM, David Blevins wrote:



On Nov 21, 2008, at 3:04 PM, JimOR wrote:


David,

Looks like OpenEJB3.1 is the culprit.  EJB3.0 with JPA 1.0.1, 1.1,  
1.2 and
1.3-SNAPSHOT work as expected, but 3.1 with any of the JPA jars  
fails.


This sample  http://www.nabble.com/file/p20631026/sample.zip  
sample.zip
should give you a head start recreating the scenario.  I had to  
remove the

OpenJPA jars to fit within the file upload size limit, drop them into
sample/lib and you should be good to go.

The sample/test folder contains the junit xml results of the test  
case under

the various classpaths.


FYI, filled a JIRA for this:

https://issues.apache.org/jira/browse/OPENEJB-970
(notifications:  
https://issues.apache.org/jira/secure/ViewIssue.jspa?id=12410384&watch=true)

Thanks for putting that sample together!

-David






Re: EntityManager Propagation Problem under 3.1

2008-12-10 Thread David Blevins


On Nov 21, 2008, at 3:04 PM, JimOR wrote:


David,

Looks like OpenEJB3.1 is the culprit.  EJB3.0 with JPA 1.0.1, 1.1,  
1.2 and

1.3-SNAPSHOT work as expected, but 3.1 with any of the JPA jars fails.

This sample  http://www.nabble.com/file/p20631026/sample.zip  
sample.zip
should give you a head start recreating the scenario.  I had to  
remove the

OpenJPA jars to fit within the file upload size limit, drop them into
sample/lib and you should be good to go.

The sample/test folder contains the junit xml results of the test  
case under

the various classpaths.


FYI, filled a JIRA for this:

 https://issues.apache.org/jira/browse/OPENEJB-970
 (notifications:  
https://issues.apache.org/jira/secure/ViewIssue.jspa?id=12410384&watch=true)

Thanks for putting that sample together!

-David



Re: EntityManager Propagation Problem under 3.1

2008-11-21 Thread JimOR


David Blevins wrote:
> 
> Hi Jim,
> 
> I'm not sure what would cause this issue.  We should try isolating  
> things so we can figure out where to look.  First thing would be either:
> 
>a. swap out the OpenJPA version in your OpenEJB 3.1 install with  
> OpenJPA 1.0.1, or
>b. take your working OpenEJB 3.0 install and upgrade your OpenJPA  
> version from OpenJPA 1.0.1 to OpenJPA 1.1.0 or OpenJPA 1.2.0
> 
> I'd go with b.  If that recreates the issue than you can rule out  
> OpenEJB and update your post on the OpenJPA list saying you know it  
> isn't an OpenEJB issue.  If it doesn't recreate the issue than we know  
> it's something on our end and we can dig deeper.
> 
> -David
> 
> 
> 
> 

David,

Looks like OpenEJB3.1 is the culprit.  EJB3.0 with JPA 1.0.1, 1.1, 1.2 and
1.3-SNAPSHOT work as expected, but 3.1 with any of the JPA jars fails. 

This sample  http://www.nabble.com/file/p20631026/sample.zip sample.zip 
should give you a head start recreating the scenario.  I had to remove the
OpenJPA jars to fit within the file upload size limit, drop them into
sample/lib and you should be good to go. 

The sample/test folder contains the junit xml results of the test case under
the various classpaths.


Thanks for your help,

Jim

-- 
View this message in context: 
http://www.nabble.com/EntityManager-Propagation-Problem-under-3.1-tp20571571p20631026.html
Sent from the OpenEJB User mailing list archive at Nabble.com.



Re: EntityManager Propagation Problem under 3.1

2008-11-19 Thread David Blevins


On Nov 18, 2008, at 4:29 PM, JimOR wrote:



Apologies in advance for cross-posting, but my post to OpenJPA (
http://n2.nabble.com/EntityManager-Propagation-with-Extended-PersistenceContext-td1495977.html
http://n2.nabble.com/EntityManager-Propagation-with-Extended-PersistenceContext-td1495977.html
)  hasn't gotten any hits.

To repeat from that post, I have:
A) Parent entity with LAZY OneToMany List, cascade:
PERSIST,MERGE,REFRESH
B) Child entity with EAGER ManyToOne Parent, cascade:  
PERSIST,MERGE,REFRESH


C)Abstract CRUD class with injected Extended PersistenceContext, and
requisite CRUD methods
D) Parent Stateful bean that extends CRUD
E) Child Stateful bean that extends CRUD

Classes are enhanced in place via ant prior to junit test run.

Under OpenEJB3.0 (OpenJPA 1.0.1), Any/All managed entities show as  
managed

by either bean, but under OpenEJB 3.1 (with deployed OpenJPA 1.1.0 AND
'latest binary' 1.2.0), only the bean responsible for the load/ 
persist/merge

of an entity shows the entity as managed.

The following snippet works fine under 3.0, but throws an exception  
under

3.1:

Parent p = parentBean.insert(new Parent("Foo"));
Child c = childBean.insert(new Child("Bar", p));

WARN
org 
.apache 
.geronimo.transaction.manager.TransactionImpl.beforeCompletion(Ln
516) - Unexpected exception from beforeCompletion; transaction will  
roll

back

org.apache.openjpa.persistence.ArgumentException: The given instance
"entity.Parent-6264" is not managed by this context.
FailedObject: entity.Parent-6264


Hi Jim,

I'm not sure what would cause this issue.  We should try isolating  
things so we can figure out where to look.  First thing would be either:


  a. swap out the OpenJPA version in your OpenEJB 3.1 install with  
OpenJPA 1.0.1, or
  b. take your working OpenEJB 3.0 install and upgrade your OpenJPA  
version from OpenJPA 1.0.1 to OpenJPA 1.1.0 or OpenJPA 1.2.0


I'd go with b.  If that recreates the issue than you can rule out  
OpenEJB and update your post on the OpenJPA list saying you know it  
isn't an OpenEJB issue.  If it doesn't recreate the issue than we know  
it's something on our end and we can dig deeper.


-David




EntityManager Propagation Problem under 3.1

2008-11-18 Thread JimOR

Apologies in advance for cross-posting, but my post to OpenJPA (
http://n2.nabble.com/EntityManager-Propagation-with-Extended-PersistenceContext-td1495977.html
http://n2.nabble.com/EntityManager-Propagation-with-Extended-PersistenceContext-td1495977.html
)  hasn't gotten any hits.

To repeat from that post, I have:
A) Parent entity with LAZY OneToMany List, cascade:
PERSIST,MERGE,REFRESH
B) Child entity with EAGER ManyToOne Parent, cascade: PERSIST,MERGE,REFRESH

C)Abstract CRUD class with injected Extended PersistenceContext, and
requisite CRUD methods
D) Parent Stateful bean that extends CRUD
E) Child Stateful bean that extends CRUD

Classes are enhanced in place via ant prior to junit test run.

Under OpenEJB3.0 (OpenJPA 1.0.1), Any/All managed entities show as managed
by either bean, but under OpenEJB 3.1 (with deployed OpenJPA 1.1.0 AND
'latest binary' 1.2.0), only the bean responsible for the load/persist/merge
of an entity shows the entity as managed.

The following snippet works fine under 3.0, but throws an exception under
3.1:

Parent p = parentBean.insert(new Parent("Foo"));
Child c = childBean.insert(new Child("Bar", p));

WARN
org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(Ln
516) - Unexpected exception from beforeCompletion; transaction will roll
back

org.apache.openjpa.persistence.ArgumentException: The given instance
"entity.Parent-6264" is not managed by this context.
FailedObject: entity.Parent-6264


Please help

Thanks,

Jim



-- 
View this message in context: 
http://www.nabble.com/EntityManager-Propagation-Problem-under-3.1-tp20571571p20571571.html
Sent from the OpenEJB User mailing list archive at Nabble.com.