I think that the "lazy load" technic you're using is wrong.
First, you are assuming that the EJB container initialize a new object each
time it has to provide a new implementation for a component contract. But,
depending of the container implementation it can be true or false. WebLogic,
for example, uses pool of objects. JOnAS doesn't provide a new instance
anymore.
Second, your "lazy load" technic doesn't take care about transaction
isolation. Indeed, the ejbLoad() is called the first time you call the bean
in a transaction. In pessimistic locking ejbLoad() has to get data from the
database and lock the tuple in the database. If you delay the load in a
service (method) the data can be inconsistent regarding the transactional
state.
Regis Le Brettevillois
CTO
LIBeLIS
http://www.libelis.com
-----Message d'origine-----
De : [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]De la part de Blasius Lofi
Dewanto
Envoye : jeudi 29 mars 2001 11:57
A : [EMAIL PROTECTED]
Objet : Re: Error in JOnAS 2.2.7
Hi Philippe, Calvin,
thanx for a fast response!
> In order to get a reference to a home object you must perform
> a JNDI lookup
> SubjectHome subjectHome =
> (SubjectHome)initialContext.lookup(homename);
> and not
> > (SubjectHome)HomeInterfaceFactory.create(
> > SubjectHome.class, SubjectHome.COMP_NAME);
I have written a helper class "HomeInterfaceFactory" that
does the same thing as what you said. This is not the problem.
Calvin said:
> I too have observed this behaviour, any local fields that haven't been
> declared as cmp-fields are not initialised.
> I assume this is part of the performance improvements made by the jonas
> team, bean instances are reused rather than created each time, hence your
> "subject" may already be pointing to some other EnrollmentBean's subject
and
> your "if (subject != null)" returns true.
> To overcome this problem you could initialise all local fields in
ejbLoad(),
> e.g.
> public void ejbLoad() {
> subject = null;
> }
You are absolutely right. I tried this and it works again.
I also saw this lazy load technique from Richard
Monson-Haefel. I also found in his book, that
this initialization should be done at ejbActivate().
The question is, if I always have to initialize
the local fields in ejbLoad() does it make any sense to
use this lazy load technique? When do I get (subject != null)?
Or how often do I get (subject != null)? I would like to
know how this works in Jonas...
Please answer directly to my email: [EMAIL PROTECTED]
Thanx,
--
---------------------------------------------------
Blasius Lofi Dewanto
---------------------------------------------------
OpenUSS - Open University Support System
http://openuss.sourceforge.net
---------------------------------------------------
E-Mail : [EMAIL PROTECTED]
ICQ : 39343280
---------------------------------------------------
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".