Wednesday, November 5, 2014

Hybris Commerce workspace settings for Eclipse/STS IDE

Recently I took up the task of setting up Hybris Commerce development environment and in the process I had to setup Hybris workspace on my eclipse and STS IDE, Hybris comes with a ton of extensions and modules and I ended up having atleast 30 different projects on my workspace to resolve the build errors, with additional projects came the requirement of increased heap memory else STS and Eclipse would either freeze or crash during the ant build phase with an out of memory error.

So here are couple of steps that should be included to support a clean Hybris commerce workspace.
There is a very detailed document on the Hybris WIKI for recommended Eclipse and STS settings so make use of these steps as a addendum to Hybris official document.

64 bit JVM

No matter which IDE you make use of it is important to make sure your system is running a 64 bit version of the Oracle JVM, 32 bit JVM has a upper limit of 2GB RAM , so to break this ceiling we need to make use of 64 bit JVM. you can validate this by running the "java -version" command, the output should be as follows and this indicates that we have a 64 bit version of the JVM.

$java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

64 bit IDE and Java Heap Setting (Eclipse or STS)

Make sure you download 64 bit version of  Eclipse or STS IDE, once you have extracted and installed the respective IDE go ahead and edit Eclipse.ini or STS.ini file and make changes to increase the max heap size, refer following file as a reference from my toolkit setup.

Java Heap Setting for the ANT Task

The heap setting defined for the IDE in the previous step is only allocated to the IDE, something that most of us misunderstand here is this heap setting does not automatically apply to the process launched within within the IDE, for instance if we launch ANT build task the heap setting is still capped at 2gb.

To increase the max heap setting within the IDE you have to set the VM arguments for the Ant Build in the Run->External Tools->External Tools Configurations dialog. Click the JRE tab and set the usual -Xmx and -Xms params as needed.

Restart the IDE and perform a ANT build, monitor the heap usage from the Task manager and you should notice that the IDE is crossing the threshold of 2GB limit now.

Sunday, November 2, 2014

Head first Chef

As a beginner it is quite challenging to understand where to begin with Chef, In this blog series on Chef I attempt to share my learning path and hopefully this will help others as well, Chef has evolved considerably in the last two years and so has the the tools surrounding this technology, not until recently the folks at chef did a great job of putting together best of breed tools and technologies and have created at SDK referred to as ChefDK. In the first series we will walk through the ChefDK installation, creation of simple cookbooks and spinning up a virtual machine in under 5 minutes.. Yeah that's what it takes to get a head start with ChefDK.



Chef Client can operate in two modes.

Local Mode – it simulates full chef server instance in memory, any data that would have been saved on server is saved locally, and this mode is used for rapid chef recipe development. We will be using this mode for our chef learning.

Client Mode – In this mode it is assumed that we have a Chef server running on another system, this mode is used in production or production like environment.

Exercise 1: Automating VM Creation 

"chef" utility was released along with the ChefDK and this streamlines various workflows associated with chef development. We will be using this utility for our cookbook generation.

>> chef generate app test_vm

This command will generate the basic template for the cookbook development, it will create a folder names hello-chef with quite a few files and sub folders in it. As a beginner we can focus on couple of files.

Take a look at the generated .kitchen.yml file and edit as follows, we are going to spin up a Cent OS VM and hence the name "centos-7.0"
Refer the Chef docs at for more details on the various parameters used in the kitchen.yml file

  name: vagrant

  name: chef_zero

  - name: centos-7.0

  - name: default
      - recipe[test_vm::default]

Now Type following command and it should list various virtual machines supported by this cookbook, in this case you should get centos listed in the output

>> kitchen list
Instance          Driver   Provisioner  Last Action
default-centos70  Vagrant  ChefZero     <Not Created>

Create the virtual machine
>> kitchen converge
Once the machine is created you should be able to login from the command prompt
>> kitchen login

Exercise 2: Automating VM Creation + Apache Server Setup

In the previous exercise we did not really write a cookbook, all we did was to tweak the generated kitchen.yml file to spin up a virtual machine.
We will now edit the recipes/default.rb file to write our first cookbook to install an Apache Webserver.

execute "update Packages" do
  command 'yum list updates'

package 'httpd' do
  action :install

service 'httpd' do
  action [ :enable, :start ]

cookbook_file "/var/www/html/index.html" do
  source 'index.erb'
  mode '0644'

Create "index.erb" under templates/default folder, we will use this as the welcome page for the Apache server.

Hello World!! from <%= node['hostname'] %>
Create the virtual machine

>> kitchen converge
Access the http server running inside the newly created virtual machine, since we created a port forwarder we should be able to access it from the host machine as follows. http://localhost:8080/
you should be able to see the page with the following content
"Hello World!! from default-centos-70"

In this blog we looked at basics of ChefDK setup and few basic examples of Cookbook creation, In the next set of articles we will look at more advanced cookbook authoring such as using a community cookbook and creating custom cookbooks.


ChefDK -
Test Kitchen -