Hello,

I am using Orion 1.3.8.  I have created a stateful session bean reference in
a JSP and saved the reference in the session.  My problem is that the
session bean doesn't timeout and I can't determine a method for removing the
bean.  I have tried to create a class implementing the
HttpSessionBindingListener in the hopes that I could call remove() on the
reference at this point, but the unbound function isn't called when the
session is invalidated.  I noticed that a bug has been reported concerning
the fact that the timeout doesn't seem to be working starting in version
1.3.8.  I've included some sample code snippets below for reference.  Any
help on a method for removing these beans when the session invalidates would
be much appreciated.

Thanks,
Dean

Sample JSP code:

<html>
<head><title>Test Session Page</title></head>
<body>
Session = <%=session.getId() %>
<ejb:useHome id="home" 
             type="test.ejb.XYZHome" 
             location="java:comp/env/ejb/XYZ" />
<%
    test.ejb.XYZ myXYZ = (test.ejb.XYZ) session.getAttribute("SESSION_XYZ");
    if (myXYZ == null) {
       System.out.println("creating and saving session bean");
       myXYZ = home.create();
       session.setAttribute("SESSION_XYZ", myXYZ);
    } else {
       myXYZ = (test.ejb.XYZ) session.getAttribute("SESSION_XYZ");
    }
%>
</body>
</html>

Bean Segment (note I've also tried a separate class than only implemented
HttpSessionBindingListener and it doesn't get called):

public class XYZBean extends Object
implements SessionBean, HttpSessionBindingListener {
    private SessionContext ivContext;           // CLient specific context
    private Hashtable ivXYZs = null;                // Client Specific State

    
    public void valueBound(HttpSessionBindingEvent event) { 
    } 
    public void valueUnbound(HttpSessionBindingEvent event) { 
      System.out.println("In the unbound function");
      try {
          ivContext.getEJBObject().remove();
      }
      catch (Exception e) {
          e.printStackTrace();
      }
    } 
        etc...

Reply via email to