Karate in Action – Rest API testing

Overview In this post we will see What is Karate and How to test Rest API with Karate Framework(BDD). Karate Karate is a complete DSL and sits on top of Cucumber-JVM. Unlike other automated API testing tools which require a good amount of coding, Karate works out of the box. Test cases are written in Gherkin style text *.feature file. A Gherkin file is saved with the “.feature” extension. In general feature file starts with Read more…

Overview of @Component, @Controller, @Repository, @Service

Overview In this post, we will go through @Component, @Controller, @Repository, @Service annotations in Spring Framework. Stereotype Annotations Spring scans and registers Beans in the ApplicationContext. We can use @Component, @Controller, @Repository, @Service depending on the use case. Let’s see them in detail @Component @Component is the most generic stereotype for any Spring-managed component which can be used across the applications. It is a class-level annotation and is instantiated by the Spring IoC engine. @Repository @Repository annotation Read more…

Server Side Pagination using jQuery Datatable

Overview In this blog, we will see how to configure Server-Side Pagination in jQuery Datatable. To activate Server-Side pagination you need to pass “serverSide”: true in DataTable configuration Datatable appends a few parameters in request call whether it’s POST/GET Few of these request parameters are Similarly, Datatable also expects a few parameters in response to load table correctly. At Server-Side there will be changes to support Pagination. Here we are using Spring Web but the logic remains Read more…

Spring Retry in Action

Overview In this blog, we will configure and use Spring Retry logic using Spring Application. For the use case where you need to re-invoke a failed operation or call a method again on failure. Spring Retry provides declarative retry support for Spring applications. Install Dependencies Link for other versions of spring-retry. Please Note: You will also need dependent jars for Spring Retry. Example 1. Enable Spring Retry in SpringBoot Application 2. Use retry logic on Read more…

RestTemplate in Spring

Overview RestTemplate reduces boilerplate code and enforces RESTful principles. In this post, we will discuss different ways in which we can use RestTemplate GET call Get entry point has two methods POST call Post entry point has the following methods Exchange call Exchange entry point gives a more generic way of using HTTP calls. We will see how we can do POST call using exchange method DELETE Common Methods Note

Jackson JSON infinite recursion problem

Overview In this blog, we will cover a very common issue that causes the Infinity loop aka (Jackson JSON infinite recursion) when using @ManyToOne and @OneToMany relation between entities and how we can resolve them. Sample Code being used Error ERROR 26260 — [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Infinite recursion (StackOverflowError); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Read more…

Use maven without Admin access on Windows OS

Overview In this blog, we will cover how to use maven without Admin access through cmd on Windows OS 10 & older versions. Prerequisites JAVA is installed (check C:\Program Files\Java\) Apache Maven zip Download Apache Maven directly from here or choose the latest zip file from here. For Windows 10 For Windows 10 users, user can update Environment Variable for logged in Account, which doesn’t requires Admin access. Search for “Edit Environment variables for your Read more…

Session Replication in Tomcat

Overview In this blog, we will cover What is Session Replication? How to configure Session replication into multiple Server running in a Cluster. Session Replication When it comes to the high availability of Application, we generally run our server as a Cluster of multiple servers running using Load Balancer. But what if I am logged in to one of the servers and the server goes down for some reason. We do have other servers in a Read more…

Configure Load Balancing with Nginx

Overview In this post, we will cover the following points What is Nginx? Install Nginx Configuring Nginx as a load balancer What is Nginx? NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. Install Nginx Once done start serevr using below command If all goes well, in a browser hit http://localhost You should see something like this Configuring Nginx as a load balancer We are going to add Read more…

Read Dynamic Object from JSON using Gson

Overview We have seen in prev post  how to use GSON to convert a JSON to Java Object and other way around In this post, we will see how to convert JSON which has Dynamic Keys. Sample JSON If you notice in above JSON Sample_01 and Sample_20 are dynamic. In this case, we can’t simply define a Java POJO and map it to this JSON. So how do we read this kind of JSON? We will use Read more…