What is role of jalosession?

The Jalo layer in hybris is depreacted, not the jalosession.

Whenever a request is made to hybris server, it may need current user details, currency, language, timezone etc to serve that request efficiently. Since HttpSession does not hold all these details, hybris came up with the concept of JaloSession.

Whenever a request comes 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.

  • Cron jobs also run in a JaloSession.
  • Each JaloSession is bound to a tenant. This cannot be changed, after the instance of JaloSession is created.
  • JaloSession is never made persistent in database.

How to split an order into multiple consignment

While fulfilling an order, some time it is necessary for business to split the order into multiple orders.

For instance, a customer orders two items A and B, now A has delivery window of 2 days, while B can be delivered in minimum 5 days. Now business has the option to either ship both items in 5 days. But what if item A is fresh, and will get destroyed in 5 days. There may be a case, where customer wants a mandatory delivery of item A within 2 days. In such situations, if business house doesn’t want to loose customer, it has no choice but to split order and ship it multiple times. This is the case of split consignment.

Now there may be various conditions, which may call for splitting the order into multiple consignments. Above example is just one of them. For example, we may want to split consignment, based on warehouse from where item will be picked up. We may want to split consignment, based on product type (fresh or ambient) etc. These situations which decides the business logic to be a case for splitting the consignments, are known as splitting strategies. We can have as many as strategy to split, as we want.

By default, hybris creates only one consignment for an order. This is done by following service.


As you can see, that the orderSplittingService accepts a list of strategies, we can create many strategies, and split our order. The actual business logic for splitting will go into strategy class.

How to customize error message in store front

Unexpected conditions is something, which is unavoidable in any application. So is Hybris store front. There may be hundreds of situations, where you would like to show an error message to users. The error could be because of, wrong user input, unavailability of data, inadequate exception handling or some thing else. But the bottom line is, it is unavoidable.

Hybris provides a very flexible and modular approach to show error messages. But your customer may still want to customize the way we show error messages in store front.

GlobalMessages class

While serving a particular request in your java classes (controllers, facades, service, dao etc), whenever you come across a error situation (like validation error or a possible null pointer etc), you should use this class. This class provides static methods to add error messages to your model object.

There are different type of messages, you can add to your model. They include confirmation message, error or warning messages.




This tag is used to actually render the error message at a particular position and some css. Now you can customize the csss as you want.


The error messages, are present in base properties. If you want to add a new type of error message to your store front, you should do that in Global message class.

Why we have converters and populators in hybris?

I can convert my models to DTO directly in facade layer. Then why should i have a converter?

Its Simple. We may need to convert a product (model) from multiple places. We convert it on product listing page, product detail page, order confirmation page etc. Hybris follows oops concept..So it is good to have a separate class to do this conversion for us, from all of these places.

Converters creates an object of DTO. While populators breaks the code for filling up data in DTO. This is required because, not each DTO needs all attributes of a model. Thus by having multiple populators, we can write more efficient code. Reverse populators are used to fill data in model from DTOs.


The image shows two paths followed (a and b) by two different facades using same converter and different poplators.

We should always use spring injected converters and  populators.

HTTP Status 500 – Cannot find CMSSite associated with current URL

This is the first error we see, when we set up Hybris and hit http://localhost:9001/

Hybris supports multi sites for a single code base, which can be accessed by passing a request parameter while accessing the site for first time. This parameter is set in browser session for subsequent requests.


When you pass the parameter site, with value same as your CMS site id, you are able to see the home page.

If you are using a single storefront, then you need to tell hybris specifically, by configuring the URL patterns for your site, so that hybris knows, what site you are looking for, when hit without a parameter. This can be dine in site.impex

UPDATE CMSSite;uid[unique=true];urlPatterns;defaultlanguage(isocode)


Why hybris deprecated tenant scope?

To understand, the meaning of tenant scope, see my previous post on scopes in hybris. With version 5.0 , hybris decided to deprecate tenant scope.

In verion 5, Hybris has tenant specific application contexts. So the bean you will get will be singleton by default, which is already limited to a tenant. So there is no need to have a different scope called tenant.




As you can see fro above picture, each tenant creates its own set of application context, so now tenant scope is redundant.

Source : Hybris Wiki

What are different scopes in Hybris?

The scope can be defined as a virtual space, situation or time line, under which a particular activity is valid or possible. In terms of Hybris, the scope is the time for which a bean is available for performing business logic.

In addition to Spring scopes, Hybris has defined below scopes.

1) Tenant : This is equivalent  to singleton scope of spring. The only difference is that here Hybris limit the instance of bean in question to a particular tenant.

Hybris has deprecated this scope in version 5.0.

2) yrequest : This scope is equivalent to request scope. But this is used out side the web application context. It means that you can access these beans even in absence of a web application. These are basically used in back end processes, where we don’t want to expose our services on web, but still want to use them from outside of our project.

Once a session is invalidated, the scope ceases to exist, and instances are destroyed.

Why Hybris deprecated Jalo layer?

Or Explain difference between Jalo layer and Service layer?

Hybris 4.3.0, deprecated the Jalo layer for item types. This means, that hybris discouraged the usage of Jalo classes to serve as utility methods for performing business logics.

Prior to service layer, Jalo classes used to have both data model logics, methods and also business logic methods.

<itemtype code=”PickingCenter”
autocreate=”true” generate=”true”>
<deployment table=”PICKING_CENTER” typecode=”22113″/>
           <attribute qualifier=”warehouseForFresh” type=”Warehouse”>
           <persistence type=”property” />
           <modifiers read=”true” write=”true” optional=”true” />
           <description>Warehouse for fresh items</description>

A sample item type in items.xml

The build framework will generate below classed for this item type:

1) An abstract class : GeneratedPickingCenter –  This class is basically a data model class, which has getter/setter for accessing data model, like attributes of data model. 



2) PickingCenter.java

Non Abstract class : This class extends the Generated class, and can have other methods for accommodating business logic.

So what is the big deal?

1) Service layer comes with the idea of segregating business logic from data model. Service layer sits inside other extensions (not necessarily) and access data layer via DAOs.  This layer is much more flexible and loosely coupled with database.

2) Think of a scenario, where you are using a legacy code, you don’t have access to source code. Had it been all Jalo, How would you override a business logic? In service layer it is easy to override, since ever service is configured as a bean, which is more adaptable to spring MVC design pattern.

3) If there is a change in database design, you need not to change your service layer necessarily. This flexibility is not available in Jalo layers.

4) In Jalo, we use like below:                                                                                                VoucheManager vm = VoucherManager().getInstance();

In Service layer,                                                                                                          private VoucherService voucherService;

So we can inject any implementation of VoucherService in our custom code, but how do we do so in Jalo. We need to break into Jalo layers.

Source : Hybris Wiki

Flexiblesearch error : could not translate value expression ‘session.catalogversion’

This error comes, when we try to access, products, cart etc from outside the context of our web application, like from custom cockpits, third party web services, or a web application within hybris container, but different web application context.


As the error suggests, it could not find the catalog basically, in the session. Since the session associated, with web application is different in our use case, it could not find the catalogs, which are generally attached to base store. A custom web application is not associated with any base store, so it has no catalog attached to it.


The cockpits developer would have faced the same issue, while developing it, and they were kind enough to give us a solution to this. They called it Impersonation.

The literal meaning of impersonation is, to act on behalf of someone else.

We need to wrap the calling code in a impersonated context. This context could be supplied with, base store, cms sites, user, order and even a catalog. Remember selecting a customer or order in cockpit. Once selected, that user/order is supplied to a impersonated session context, and available to wrapped code to process.

The cmsSite and catalogVersion can be get by service layer convenient methods at disposal.

Once we call our business logic inside execute method, it has catalog version in session.




Set up a MVC application in hybris


There are times, when OOB cockpits, applications are not sufficient for client requirements.  Customizing cockpit is often a tedious task as it involves struggle with adamant ZK framework.


Hybris never discouraged us to create more flexible MVC applications and still use the powerful platform features. This acts just like other full fledged application and run inside same hybris server.
1. Create a new extension. Let’s call it Backoffice.