users@glassfish.java.net

Glassfish 2.1.1 - Session Beans not in the Session

From: <glassfish_at_javadesktop.org>
Date: Thu, 23 Sep 2010 05:58:09 PDT

I have a Web Application that I'm trying to move from Sun Application Server V9 to Glassfish V2.1.1

I'm using Netbeans 6.0.1 to develop the App, and it's using JSP, SessionBeans and JDBC to connect to MySQL.

I've made good progress and can compile and deploy the App. to Glassfish OK.
The App starts and I takes me to my login page, where I can login OK.

However, None of my SessionBeans seem to remember their state or get into the session space, and I can see the init() and destroy() methods being called many times as each JSP page is rendered.

My Session Bean extends AbstractSessionBean

<code>
public class SessionBean1 extends AbstractSessionBean {
</code>

Using Netbeans Debug tool I have tracked down the the LifecycleListener.attributeReplaced(HttpSessionBindingEvent event) method that calls the destryo() and init() methods on my AbstractSessionBeans

<code>
    public void attributeReplaced(HttpSessionBindingEvent event) {

        // If the old value is an AbstractSessionBean, notify it
        Object value = event.getValue();
        if ((value != null) && (value instanceof AbstractSessionBean)) {
            ((AbstractSessionBean) value).destroy();
        }

        // If the new value is an AbstractSessionBean, notify it
        value = event.getSession().getAttribute(event.getName());
        if ((value != null) && (value instanceof AbstractSessionBean)) {
            ((AbstractSessionBean) value).init();
        }

    }
</code>

In Netbeans 5.5 and Sun Application Server V9 the AbstractSessionBean Session Beans work fine and remember their state and don't have their init() and destroy() methods() called all the time.

I've checked that my Session Beans are in the faces-config.xml.

So, my feeling is that it's my configuration of Glassfish 2.1.1...

Please can you help?

Thanks
[Message sent by forum member 'sgreenslade']

http://forums.java.net/jive/thread.jspa?messageID=483439