Hi everybody,
I've stumbled across some odd behaviour by JBoss (CVS as of end
January 2001, but the affected pieces of code have been untouched
since then so this should be reproducible with a current CVS build):
Upon passivation of a stateful session bean I get the following
exception:
[Container factory] java.rmi.ServerException: Could not passivate; nested exception
is:
[Container factory] java.io.NotSerializableException: javax.naming.InitialContext
[ Remaining output deleted as its not relevant ]
The "problem" is that my stateful session bean has a variable like
this:
public javax.naming.Context jndiContext;
which is initialized in setSessionContext() method as
jndiContext = (javax.naming.Context) new InitialContext();
Apparently, InitialContext is not serializable (which is fine with me
:), but according to the specs, Section 6.4.1 (p. 51) this is not even
necessary:
"..., the references to the java:comp/env JNDI context and its
subcontexts, ..."
as the container (i.e. JBoss) should take care of this (page 52, in
the lower half of the page):
"If the session bean instance stores in its conversational state an
object reference to the java:comp/env JNDI context or its subcontext,
the container must be able to save and restore the object references
across the instance's passivation. The container can replace the
original object with a different and functionally equivalent object
during activation."
The same facts are stated in the O'Reilly book "Enterprise Java Beans
2nd Edition" by Richard Monson-Haefel, pages 251-252 and page 269.
So, what now? My current solution to this problem is that I have
disabled stateful session bean passivation in standardjboss.xml but
this cannot be a "real" solution :). Another solution (for me as an
application developer) would be to adapt my ejbPassivate() and
ejbActivate() methods accordingly, setting jndiContext to 'null' upon
passivation and re-instating it upon activation but according to the
specs I should not be responsible to do this.
The class that would have to be "fixed" is
org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager
I would do it myself but as I don't have CVS write access and there
surely /have/ to be people who know how to implement the necessary
changes far better and quicker than me, I would appreciate it if
someone could do this :)
Best regards,
Christian
--
Riege Software International GmbH Phone: +49 (2159) 91 48 - 0
Mollsfeld 10 Fax : +49 (2159) 91 48 - 11
40670 Meerbusch, Germany http://www.riege.com/
----------< the apprentice master of the 'sendmail' daemon >----------