So I have to ask why this logic should work at all since you are describing a circular processing chain. The real question would be why it did not fail previously.
Yes. Having one object init another which inits a new instance of the first would obviously never work. This application, however, has been working for over a year now.
My assumption is that the circular referencing problem can be avoided with EJBs (and must have been with previous versions of JBoss) because, using the previous example, the local (proxy) ref being requested by BeanC would NOT require a NEW instance of BeanA, so BeanA's ejbCreate would not be called again (these are stateless session beans).
I was just wondering if the way the container pools stateless session beans changed, and/or whether there is a configuration change that I can make to avoid this.
Nothing comes to mind as to what change would introduce differing pooling behavior. Similarly, I don't know why this ever should have worked.
Previously, home.create() only created the proxy to the ejb. It didn't try
to create the ejb instance.
This change is incomplete anyway, since the home.create() might suceed,
but some other thread takes that instance and the remote/local method
still has to create another instance and that might fail.
The UndeclaredThrowableException should not be happening.
It should be throwing an EJBException if it cannot create an instance to satisfy
a particular request.
What the user is doing is clearly not portable, since the EJB spec
does not mandate lazy construction of instances like the 4.0.1sp1 pooling code,
though I imagine most appservers have some config parameter to enable
I should remember changes I make ;)
I wanted to thank you Scott and Adrian for taking the time to respond. To upgrade to 4.0.2, we have removed the circular references causing the above problems and everything seems fine.
The ability to lazy init session bean instances does sound appealing in some circumstances, though...
Has anyone put forth a lazy init param for the SLSB? We have a large app we are migrating to 4.0.2 affected by this.
I am also getting same problem which is in discussion.
Please suggest me if you are able to figure out lazy init for SLSB in JBOSS 4.0.2 or any other work around.
Thanks and regards
I've receieved a few e-mails about this and I just wanted to follow up. It is ok if one ejb init inits another ejb...only when there is an initing loop back to a bean in the init chain do you run into trouble. So we went through the code and found only those places where there is a loop and moved the initing into the actual ejb method calls, a.k.a., makshift lazy initing.
Hope this helps,