Well,
My mail did not receive a lot of attention. Surely my explanations...
So I "retrousse mes manches" and I "ai sauté dans le code".
The correct solution seems to free "ejbObject" in the clear() method of
EntityEnterpriseContext.
public void clear() {
super.clear();
this.invoked = false;
this.valid = false;
key = null;
persistenceCtx = null;
/*****/ ejbObject = null;
}
Can some gurus, masters, gods, ... whatever, verify that and commit it.
A more detail explanation of the problem follows :
I have one EntityBean UsersDO (pk, login)
And one method getAuthorizations() that make a ctx.getEJBObject() somewhere
in it.
I decide to debug this value because it is -sometimes- wrong.
UserDetail rdetail=new UserDetail("root","b","c","d");
UsersDO root=uhome.create(rdetail);
/*1*/ root.getAuthorizations();
UserDetail udetail=new UserDetail("user","b","c","d");
UsersDO user=uhome.create(udetail);
/*2*/ user.getAuthorizations();
/*3*/ root.getAuthorizations();
If I debug the value of
x - ctx.getEJBObject()
ctx
in getAuthorizations() I have
1 - Users:com.hm.base.domain.security.interfaces.UsersDOPK@538e2bde
org.jboss.ejb.EntityEnterpriseContext$EntityContextImpl@3b5ba
2 - Users:com.hm.base.domain.security.interfaces.UsersDOPK@538e2bdd
org.jboss.ejb.EntityEnterpriseContext$EntityContextImpl@3b5ba <==
Pool
reuse
3 - Users:com.hm.base.domain.security.interfaces.UsersDOPK@538e2bdd <==
Oops !
org.jboss.ejb.EntityEnterpriseContext$EntityContextImpl@3b5ba <==
Pool
reuse
The -3- is not correct.
It gives an EJBObject that link to the other entity bean instances
In fact the -3- is -sometimes- corect, depending of the Pool Max Size I
defined in the Container COnfigurations.
So -sometimes- when I run the code I have no problem.
I have so 1 time on 6 :
1 - Users:com.hm.base.domain.security.interfaces.UsersDOPK@51919256
org.jboss.ejb.EntityEnterpriseContext$EntityContextImpl@34df9c
2 - Users:com.hm.base.domain.security.interfaces.UsersDOPK@5191ef6d
org.jboss.ejb.EntityEnterpriseContext$EntityContextImpl@34df9c <==
Pool
reuse
3 - Users:com.hm.base.domain.security.interfaces.UsersDOPK@51919256
org.jboss.ejb.EntityEnterpriseContext$EntityContextImpl@53f141 <==
Pool
refreshed
You can see that the EnterpriseContext (ctx) is always reused for my second
entity bean instance.
Which sometimes cause no problem, sometimes it does.
Vincent.
-----Message d'origine-----
De : [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]De la part de
Vincent Harcq
Envoyé : vendredi 23 mars 2001 14:52
À : Dev JBoss
Objet : [JBoss-dev] AbstractInstancePool - free()
Hi,
The problem I have comes originally from the fact that I use
ctx.getEJBObject() to get, inside an Entity Bean, the Remote Interface
itself to send it as a parameter of a finder method of another EntityBean
linked to it by a field where I store this Remote Interface.
Breathe ;)
Please read this as for me there is a bug somewhere.
My problem (running latest CVS, HSQL, CMP) :
1. find on Entity Bean DATA
2. Call USER.GETTHING
This method calls ctx.getEJBObject() and receive "USERCTX"
Then do something with this EJBObject.
3. Call USERNEW=USERHOME.CREATE()
Here EntityContainer.createHome is called
This calls createEntity by giving him mi.getEnterpriseContext()
This is set in EntityInstanceInterceptor.invokeHome()
By Calling AbstractInstancePool.get()
The EnterpriseContext attached to USERNEW is the same as for USER
because
free() has been called which has re-put the EnterpriseContext in the stack.
Then CMPPersistenceManager make a ctx.setEJBObject and because ctx is
the
home of USER, change ejbObject of USER with the value of USERNEW
! THAT IS MY PROBLEM !
4. find on Entity Bean USER
5. Call USER.GETTHING
This method calls ctx.getEJBObject() and receive "USERNEWCTX"
! Aarrrrghhhh !
The ctx of USER is different of the ctx of USERNEW which is fine.
The problem is on the ejbObject inside ctx.
Again breathe.
Am I clear ? (it is not really clear for me).
My Solution :
In AbstractInstancePool :
public synchronized void free(EnterpriseContext ctx)
{
// Pool it
//DEBUG Logger.debug("Free
instance:"+ctx.getId()+"#"+ctx.getTransaction());
ctx.clear();
/** DO NOT RE_PUT THE CTX IN THE STACK BUT ALWAYS DISCARD IT
* if (pool.size() < maxSize)
* {
* pool.push(ctx);
* } else
* {
*/
discard(ctx);
/**
}
*/
}
I do not think my solution is THE solution but only a work around. But
really I have to confess it's still too hard for me to get the whole picture
to be able to correct it.
Vincent.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development