Sunday, March 31, 2019

Simple React + Redux example

In the previous article we have seen Spring boot with react example. In this example we will see how to configure React with Redux. Now what is all this fuss about Redux?

In simple term Redux is used to manage state of your application. As your application starts growing it gets difficult to manage state of your application. This is when Redux comes to help you.

Redux data flow

Lets see a simple counter example. Assuming npm is already installed in your machine. If not, install npm.

Saturday, March 23, 2019

Spring Boot + ReactJS hello world example

Spring Boot is designed to get you up and running as quickly as possible, with minimal upfront configuration of Spring. To know more about spring boot, click here.

ReactJS is a JavaScript library used for building user interfaces. To know more about react, click here.

In this example spring boot will exposed our business logic using rest endpoints and reactjs is used as frontend user interface. Point here to be noted is unlike a traditional web application where java codes + web code (HTML + javascript + css) are residing in same project here spring boot and reactjs will be in different project. The main advantage of this type of setup is to have a loose coupling between your UI and business logic. Tomorrow if you feel to replace reactjs with anjularjs or vuejs you can very well do it without touching business logic.

Step 1 -
Create a spring boot application, click here for more details.


Monday, January 14, 2019

Hello World Parameterized Junit Test

In this article we will see how to build a Parameterized Junit Test.

Parameterized tests was introduced with JUnit 4. Basic concept of Parameterized tests is to run the same test over and over again using different inputs.

There are 4 steps involve in this -

  • Annotate the test class with @RunWith(Parameterized.class)
  • Create a public static method annotated with @Parameterized.Parameters that returns a Collection of Objects as test data set
  • Create a public constructor that takes input as a single data item from step 2
  • Create an instance variable for each item of test data

Lets see the example -

Created a maven project as shown below -


Saturday, October 6, 2018

StackOverFlowError: Causes & Solutions

StackOverFlowError is one of the common confronted JVM error. In this blog post lets learn inner mechanics of thread stacks, reasons that can trigger StackOverFlowError and potential solutions to address this error.

To gain deeper understanding in to StackOverFlowError, let's review this simple program:

public class SimpleExample {

      public static void main(String args[]) {

      public static void a() {

            int x = 0;

      public static void b() {

            Car y = new Car();           

      public static void c() {

            float z = 0f;

This program is very simple with following execution code:

1.       main() method is invoked first
2.       main() method invokes a() method. Inside a() method integer variable ‘x’ is initialized to value 0.
3.       a() method in turn invokes b() method. Inside b() method Car object is constructed and assigned to variable ‘y’.
4.       b() method in turn invokes c() method. Inside c() method float variable ‘z’ is initialized to value 0.

Now let’s review what happens behind the scenes when above simple program is executed. Each thread in the application has its own stack. Each stack has multiple stack frames. Thread adds the methods it’s executing, primitive data types, object pointers, return values to its stack frame in the sequence order in which they are executed.

Fig 1: Thread's Stack frame.

Java - Cucumber Hello World example

In the previous article we have seen JBehave Hello World example. In this article we will see same Hello World example but with using Cucumber.

Like JBehave, Cucumber is also used for behavior-driven development (BDD) testing. To know more about Cucumber click here.

Below is the eclipse folder structure -