Friday, March 9, 2018

Quick Installation of Vault and Consul

I would like to cover a quick and simple setup of Consul and Vault for learning purpose. These steps short circuit a real world advanced setup options.

Download the proper package for OS and architecture from

Download Consul
Download Vault

Consul Setup -
write a shell or batch file with following command
E.g. consul_start.bat with following content
consul agent -ui -server -data-dir mydata -advertise -bootstrap-expect 1
Vault Setup -
write a shell or batch file with following command
E.g. consul_start.bat with following content
vault server -config=vault-example.hcl
vault-example.hcl content
backend "consul" {
listener "tcp" {
  address = ""
  tls_disable = 1
disable_mlock = true
C:\_workarea_\tools\vault_0.9.5_windows_amd64>vault operator init
[0;31mError initializing: Put http: server gave HTTP response to HTTPS client [0m

The default address of the client uses https. Just set the -address parameter or set the VAULT_ADDRESS env var and you'll be good to go.
vault operator init -key-shares=5 -key-threshold=2

-key-threshold - This defines the number of keys required to unseal vault
-key-shares - This defines number of keys that should be generated during initialization

[0;0mUnseal Key 1: 45MbjNghzYmFjaagC5Fcx4qj5E2jOl5ZWYByFctXV+T3 [0m
[0;0mUnseal Key 2: Z/TffCSL0mUw4NbMbHpf0dEjGge5iSZja6C7dEoY1AP1 [0m
[0;0mUnseal Key 3: C5YvqiPS20VgtiPPDuqgEwsAt6+qPE0+qO7P8zyqCEJf [0m
[0;0mUnseal Key 4: WLazf5dhHIQUSnOLLi5z29WFaLwD9ap9XASKbgHXXuc0 [0m
[0;0mUnseal Key 5: O1fgO9aT38klIVemz6q5WCXlpQaFS4jjxByaACco9Ga4 [0m
[0;0m [0m
[0;0mInitial Root Token: 4360d91f-cf9d-a33f-45ca-2bdc699caef1 [0m

Make a note of at least two Unseal keys and your root keys

unseal is a one time process as long as your backend does not change.

Now, let us unseal by running this command twice, provide atleast two unique unseal key from the init operation
vault operator unseal
Unseal Key (will be hidden):
Login, by making use of Root token that was generated during init process

vault login <Root Key>
Now , let us run commands to store and retrieve key/value sercrets
vault.exe write secret/my-app/s3password value=s3qwqwq
vault.exe read secret/my-app/s3password
You may also login from the UI and navigate to view the stored key/values

Saturday, January 6, 2018

Reactive Programming in Java using RatPack

For starters, Ratpack is built on the same non blocking, event driven, model as Node.js
This type of non-blocking and asynchronous programming model has become very popular of late
Although, asynchronous programming has many advantages, such as predictive performance behavior under load, it is equally challenging and tricky to implement this style of programming.

Ratpacks value proposition comes from it's ability to abstract some of the complexities associated with asnyc. programming model at the same time provide integration with best in class Java librariries to implement modern day application.

Development Environment
Unbuntu 17.10
Oracle JDK 9.0.1
Sublime V3.0

I would strongly recommend SDKMan while programming on Linux as it simplifies management of multiple versions of software packages. 

Getting started with a helloworld code is two step process and takes under a minute.

start with a gradle file definition

File: build.gradle

buildscript {
  repositories {
  dependencies {
    classpath "io.ratpack:ratpack-gradle:1.5.1"

apply plugin: "io.ratpack.ratpack-groovy"
apply plugin: "idea"

repositories {

dependencies {
  runtime "org.slf4j:slf4j-simple:1.7.25"

File: src/ratpack/ratpack.groovy

import static ratpack.groovy.Groovy.ratpack

ratpack {
    handlers {
        get {
            render "Hello World!"
        get(":name") {
            render "Hello $!"

Run Ratle server
gradle run

This should bring up the server on http://localhost:5050/

Refer official guide for more details on Ratpack programming

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.