This content has been marked as final. Show 5 replies
I think sharing sessions is possible only with .war files and not with the application(.ear files), my opinion is that, sessions are bound with application therefore any module/component within the application can make a reference to the session. On the other hand, a module/component, in a different application will know only it's session to which the .ear file has binded into and therefore not possible to access session which is established by a different application.
Developer Technical Support
According to the spec, Sessions aren't suppose cross WARs. However, with IBM's Websphere, you are able to "enable" "Shared Session Context" across multiple WARS in a single EAR and provided the virtual domains for each WAR are the same.
This is nice because it gives a developer the flexibility to logically breakup a large site into multiple war applications under the same EAR without having to worry about session management. For example, you can have a BrochureWAR, LoginWAR and a MemberForumWAR, MemberPaymentWAR, etc... all in the same EAR. The LoginWAR would put a UserObject into Session and the other MemberWARs could use it. Otherwise you would have to use the dreaded EJB solution or roll-your-own webservice state machine.
As a quick note, be sure that any Object you put into the Shared Session Context is loaded using the Server's classpath and not the WAR's classpath. If you don't and you load a FooObject from WAR1 lib into session, a read from Session by WAR2 will throw a ClassNotFound error because of differing classloaders. Know what I mean?
Now with all that said, I want Shared Sessions across EARs (obviously for WARs of the same domain of course). In this way, I would be able to completely remove/upgrade certain area's of a Very Large webappliction without effecting other areas for example: someWebSitesMemberPaymentEAR without effecting someWebSitesMemberForumEAR. Of course I could achieve this with all webapplications calling some Stateful WebService or EJB thing backend too but GOSH... thats alot of work for Session Management across EARs. Where's the easy button?
Did you ever solve this? i am struggling with a similar idea. I have a "very large" application which I want to make more modular so I can upgrade/add/redeploy parts, both in the Web container and the EJB container, without having to build an entirely new set of EJB-jars, wars, ear and redeploy.