Jalo session in Hybris
In normal web applications, we will have HTTP session to manage the user session
In Hybris, in addition to this HTTP Session, we also have Jalo session
Jalo session basically wraps us the data about currently logged in User and their settings
It is used as a base context using which user requests will be processed.
Every request to hybris application is associated with Jalo session
Whenever a request is made to Hybris, the filter HybrisInitFilter creates an object of JaloSession.
Every JaloSession object is associated with a SessionContext object, which has current user, language, currency etc and the current httpSession object.
Whenever Jalosession is instantiated SessionContext is pre-set with system defaults values.
- JaloSession session = JaloSession.getCurrentSession()
JaloSession session = JaloSession.getCurrentSession()
This method will return the currently active JaloSession or create a new JaloSession if none is currently active
How to close Jalo Session ?
We can specify the timeout or we can manually close it
default.session.timeout property already set by hybris in project.properties where Jalo session expires after the seconds specified in this property automatically.
We can also specify expiration time explicitly as below
- JaloSession.getCurrentSession().setTimeout( 10 ); //Timeout after ten seconds:
- JaloSession.getCurrentSession().setTimeout( -1 );// No timeout:
JaloSession.getCurrentSession().setTimeout( 10 ); //Timeout after ten seconds: JaloSession.getCurrentSession().setTimeout( -1 );// No timeout:
We can manually close it as below
- JaloSession.getCurrentSession().close();
JaloSession.getCurrentSession().close();
Why do we need JaloSession when we already have HttpSession ?
Whenever a request is made to hybris application, it always requires current user details, currency, language, timezone etc to serve that request in a more appropriate way.
Since HttpSession does not hold all these details, hybris is using the concept of JaloSession to store these required values and use them in the application.
Note :
The hybris Suite will not allow users or CronJobs to use closed JaloSessions. If a user tries to log into the hybris Suite (shop application, hMC, etc), the hybris Suite will create a new JaloSession for the login process.
JaloSessions are bound to the tenant at instantiation, you can’t use one single JaloSession across a multi-tenant system (that is, using one single JaloSession to manage multiple tenants is not possible). Instead, you will have to use at least one JaloSession per tenant.
[m java.lang.NullPointerException: while trying to invoke the method de.hybris.platform.jalo.JaloSession.getAttribute(java.lang.String) of a null object loaded from local variable ‘jaloSession’
INFO | jvm 1 | main | 2019/12/05 19:40:33.243 | at de.hybris.platform.servicelayer.session.impl.DefaultSessionService.getOrBindSession(DefaultSessionService.java:217) ~[coreserver.jar:?]
Hi, can you help me find the reason behind this?
I know the system is unable to find the JaloSession but what can be the reason of not getting it.
Thank for KB. It is very interesting, but I can not find answer for question:
Can JaloSession be longer than HTTPSession or HTTPSession can be longer than JaloSession??
And can JaloSession and HTTPSession be independent of each other?
I will be very grateful for your reply.
Hi Oleksandr,
JaloSession is bound to an HttpSession and has the same life time. It means if an http session is closed or expired, the hybris session will also be destroyed
Hi ,
Nice explanation of every topic in Hybris.
It will be very helpful if you also cover the topics related to Order and payment .
Thank u KB
Perfect , nicely described – Cheers
Thank You KB Good Info…