Ignoring Unrecognized JSON Fields With Spring & Jackson

March 13, 2015 by

If you try to bind JSON to an object in Spring MVC with Jackson, then you might have seen the below error before. Could not read JSON: Unrecognized field \”something\” (class com.codingexplained.user.dto.account), not marked as ignorable […] This error occurs whenever an unknown field is encountered in the JSON; that is, a field specified in the JSON is not… read more

Moving .ebextensions to root in .war file

March 6, 2015 by

If you wish to deploy your application to Amazon’s Elastic Beanstalk, then you can customize your server setup by placing configuration files within a .ebextensions directory within the root of your .war file (for web applications). These files can then contain various kinds of instructions. One can install packages with package managers such as yum or… read more

Unpacking War File on OS X and Linux

March 6, 2015 by

If you have packaged a web application within a .war file, then you might want to check the contents of it for various reasons. There are a number of tools that can do this, but I am going to show you a simple command that can display the contents of the war file within the… read more

Date Parameter in Spring MVC Controller

March 1, 2015 by

Need to pass a date as a java.util.Date instance in a Spring MVC controller action? Then you have come to the right place. You might have tried the below approach and encountered a good old 404 Not Found error. @Controller public class CompanyController { @RequestMapping("/company/added-since/{since}") public String showAddedSince(@PathVariable("since") Date since) { return "companies-added-since"; } }… read more

Resetting PostgreSQL Sequence

February 21, 2015 by

Okay folks, this is going to be a short one! Sometimes you may want to reset a PostgreSQL sequence, for instance after removing data from a tabel. You can do this very easily by executing the following statement: ALTER SEQUENCE company_id_seq RESTART WITH 1; company_id_seq is the name of the sequence that you want to… read more

Neither BindingResult nor plain target object available as request attribute

February 21, 2015 by

If you are trying to bind a Spring MVC form to a bean, then you might have come across the below exception. Neither BindingResult nor plain target object for bean name ‘mybean’ available as request attribute Some tutorials claim that you can do like this: @Controller public class PersonController { @RequestMapping(value = "/person/add", method =… read more