Skip to main content

SessionListener not firing

13 replies [Last post]
mramadoss
Offline
Joined: 2008-05-31

My HttpSessionListener class is not getting fired when running under Glassfish, We are using Ver 9.1_02.

However the same application fires the SessionListener's sessionCreated & sessionDestroyed methods when deployed under TomCat.

My web.xml contains the following entry:

com.ses.tims.server.TimsSessionListener

I restarted the domain also.

Will appreciate help!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cf126330
Offline
Joined: 2005-03-29

Sekhar: The original web.xml doesn't indicate the version. So if it's servelt version 2.3 or earlier, it uses dtd and the order is significant, and it would be invalid web.xml. You are right in that in version 2.4 or later schema, top-level element order no longer matters. I would always first validate web.xml (If open in NetBeans, right click and choose Validate XML.).

mramadoss: You can also run $glassfish.home/bin/verifier
Deploying the same app to 2 domains should not be an issue.

-cheng

mramadoss
Offline
Joined: 2008-05-31

Finally....

I was hand-editing the web.xml generated by the GWTDesignerTool to include the SessionListener, after the deployment and then was restarting the glassfish. Apparently glassfish is not recognizing the changes to web.xml, post-deployment. When I unjarred and edited the web.xml and rejarred my war file and then deployed, the sessionlistener started working in glassfish.

Interesting to note that TomCat reconfigures when I edit the web.xml post deployment whereas glassfish does not!

Thanks for all your help.

sekhar
Offline
Joined: 2003-06-25

Glad to note that you found the source of the problem. One note though.

GlassFish v2 supports Dynamic Reloading.

a. copy changes to class files and/or deployment descriptor to the deployment directory, which is:
- domain-dir/applications/j2ee-modules/module-name/.reload ( for Java EE applications )
- domain-dir/applications/j2ee-modules/module-name (for modules)

b. create a .reload file e.g.
- domain-dir/applications/j2ee-apps/app-name/.reload
- or domain-dir/applications/j2ee-modules/module-name/.reload
and update the timestamp on the reload file every time you make changes.

Does the above work ?

mramadoss
Offline
Joined: 2008-05-31

Yes! .reload works great.

Thanks

sekhar
Offline
Joined: 2003-06-25

Cheng: Why is the element order incorrect ? The web-app_2_5.xsd is indicating an unbounded choice which allows XML elements (servlet, servlet-mapping and listener in this example) to be ordered in any way. And the servlet spec specifies that listeners are called in the order in which they are listed in web.xml . But in this case, there is only one listener class. Thus the ordering of element is a non issue. Can you clarify where element order is incorrect ?

mramadoss
Offline
Joined: 2008-05-31

I have two domains created for DEV & QA, and the (same) application is deployed in each of these domains. Does it make a difference?

jluehe
Offline
Joined: 2004-12-01

Did you see any errors in the server.log during initial deployment?

mramadoss
Offline
Joined: 2008-05-31

No errors in server.log.

cf126330
Offline
Joined: 2005-03-29

Your web.xml is invalid. The element order is incorrect, and it doesn't have dtd or schema declaration. It seems Tomcat is more lenient in this regard. I suggest adding the following


-cheng

jluehe
Offline
Joined: 2004-12-01

Shouldn't deployment to GlassFish have failed in this case, or at least logged a warning?

mramadoss
Offline
Joined: 2008-05-31

The web.xml is generated by GWTDesigner tool. I have now included the dtd declaration in the file also. Still the listener is not firing....

I moved the
element to the bottom and tried as well.

Do you need any other config. info?

Thanks,
Mukund

sekhar
Offline
Joined: 2003-06-25

Is the listener package in war file ( under WEB-INF/classes or in a jar under WEB-INF/lib ) ?

mramadoss
Offline
Joined: 2008-05-31

The listener class is in a jar file under WEBINF/lib