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 5.7.0.5, 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.name=myb2c -Dinput.package=org.myb2c  

Added following to localextensions.xml

  1. <hybrisconfig xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 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' />  
  10.       
  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'/-->  
  17.       
  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"/>  
  27.   
  28.   
  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.name=myb2c -Dinput.package=org.myb2c  

Navigate to

Workaround for the issue

3 properties should be added for the custom storefront in local.properties

  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.