Sunday, January 31, 2016

NPE thrown while accessing Hybris custom b2c_acc_responsive storefront

This issue seems to have plagued Hybris commerce suite right from version 5.6 to the most recent version, There have been several solutions being discussed on the hybris expert forums to workaround the issue. However, I wanted to share the official answer from SAP to workaround this error.

NPE exception while accessing custom store generated using modulegen

Steps for Reconstruction

>install.bat -r b2c_acc_responsive  
>ant all  
>ant modulegen -Dinput.module=accelerator -Dinput.package=org.myb2c  

Added following to localextensions.xml

  1. <hybrisconfig xmlns:xsi='' xsi:noNamespaceSchemaLocation='../bin/platform/resources/schemas/extensions.xsd'>  
  2.   <extensions>  
  3.     <path dir='${HYBRIS_BIN_DIR}' />  
  4.     <extension name='mcc' />  
  5.     <extension name='backoffice' />  
  6.     <extension name='commercesearchbackoffice' />  
  7.     <extension name='commerceservicesbackoffice' />  
  8.     <extension name='solrfacetsearchbackoffice' />  
  9.     <extension name='solrserver' />  
  11.     <!-- OOB Store -->      
  12.     <!-- https://localhost:9002/yacceleratorstorefront/electronics/en/?site=electronics -->  
  13.     <!--extension name='yacceleratorcockpits' />  
  14.     <extension name='yacceleratorinitialdata' />  
  15.     <extension name='yacceleratorstorefront' />  
  16.     <extension name='yacceleratorfulfilmentprocess'/-->  
  18.   <!-- Custom Store -->  
  19.   <!-- https://localhost:9002/myb2cstorefront/electronics/en/?site=electronics -->  
  20.   <extension dir="${HYBRIS_BIN_DIR}/custom/myb2c/myb2ccore"/>  
  21.   <extension dir="${HYBRIS_BIN_DIR}/custom/myb2c/myb2cfacades"/>  
  22.   <!--extension dir="${HYBRIS_BIN_DIR}/custom/myb2c/myb2ctest"/-->  
  23.   <extension dir="${HYBRIS_BIN_DIR}/custom/myb2c/myb2cfulfilmentprocess"/>  
  24.   <extension dir="${HYBRIS_BIN_DIR}/custom/myb2c/myb2cstorefront"/>  
  25.   <extension dir="${HYBRIS_BIN_DIR}/custom/myb2c/myb2cinitialdata"/>  
  26.   <extension dir="${HYBRIS_BIN_DIR}/custom/myb2c/myb2ccockpits"/>  
  29.     <extension name='yaddon' />  
  30.     <extension name='ycommercewebservices' />  
  31.     <extension name='electronicsstore' />  
  32.     <extension name='apparelstore' />  
  33.     <extension name='liveeditaddon' />  
  34.       <extension name='acceleratorwebservicesaddon' />  
  35.   </extensions>  
  36. </hybrisconfig>  

>install.bat -r b2c_acc_responsive  
>ant all  
>ant modulegen -Dinput.module=accelerator -Dinput.package=org.myb2c  

Navigate to

Workaround for the issue

3 properties should be added for the custom storefront in

  1. myb2cstorefront.additionalWebSpringConfigs.liveeditaddon=classpath:/liveeditaddon/web/spring/liveeditaddon-storefront-web-spring.xml  
  2. cmsPageBeforeViewHandler=org.myb2c.storefront.interceptors.beforeview.CmsPageBeforeViewHandler  
  3. uiThemeResourceBeforeViewHandler=org.myb2c.storefront.interceptors.beforeview.UiThemeResourceBeforeViewHandler  

after that, please do  'ant clean all', and restart hybris server
Navigate to

A defect has been logged with hybris to fix this issue in version 5.7, until the fix is available you may use the workaround provide by SAP to circumvent this error.

Thursday, October 22, 2015

Working with HSQLDB and Hybris


Hybris by default includes HSQLDB as the embedded DB for development mode, Out of the box option to query database includes running Flex or SQL query from the admin console.
In this blog we explore few other convenience options to query the database by making use of external SQL clients, we further explore the option of configuring Hybris with a standalone version of HSQL server

Hybris Version:
HSQL DB Version: 2.2.9

Embedded Database

By default hybris creates embedded database data file at ~/hybris5602/hybris/data/hsqldb/ , the data file name is mydb
We will provide this information while connecting from SQuirrel SQL Client or any other client of your choice.


Standalone Database Server

You may refer following WIKI link to verify the supported version of DB

Create with following content, this configuration will create a database with the name hybris running on port 9999

#Hybris DB configuration file
# Databases:
# =====
# Other configuration:
# Port
# Show stuff on the console (change this to true for production):
# Don't show JDBC trace messages on the console:
# Do not allow remote connections to create a database:
# =====

HSQLDB download does not include a startup script by default for MAC OS or Unix, you may create a startup script as follows.
java -cp ../lib/hsqldb.jar org.hsqldb.server.Server --props ../../datafile/
Make the script executable chmod 777
Run the server by executing
This should start the new DB server on port 9999

Try connecting from SQuirrel SQL client first.
You may use username SA and blank password to connect, however, it is recommended to make use of a non  - DBA user account.


Add following in


Perform ant all
Start server and initialize to load schema and tables to the new standalone database.
you should now be able to connect to the database using SQL Client as follows.