Home » Java

Java

Handle custom exception types in JAX-RS

java-interview-questions-answers

JAX-RS supports handling custom exceptions — thrown in either EJBs or CID beans — to custom HTTP responses. Assuming we have an “exceptional” EJB: @Stateless public class Hello { public String greeting() { if (new Random().nextBoolean()) throw new GreetingException("Could not greet"); return "hello"; } } @ApplicationException public class GreetingException extends RuntimeException { public GreetingException(String message) { super(message); } } The EJB is used in ...

Read More »

Learning to use Wholly GraalVM!

Introduction In the post Truffle served in a Holy Graal: Graal and Truffle for polyglot language interpretation on the JVM, we got a brief introduction and a bit of deep dive into Graal, Truffle and some of the concepts around it. But no technology is fun without diving deep into its practicality, otherwise its like Theoretical Physics or Pure Maths ...

Read More »

Adding a “lite” Groovy web console to a Grails war

Suppose you have a Grails application deployed to a server – how would you go about finding out how the application was configured? If you have the source then you can view Config.groovy, BuildConfig.groovy, etc. (in this case I’m talking about a Grails 2 app but these ideas are generalizable to Grails 3+) but that’s often not enough. Grails 2 ...

Read More »

Spring Webflux – Writing Filters

spring-interview-questions-answers

Spring Webflux is the new reactive web framework available as part of Spring 5+.  The way filters were written in a traditional Spring MVC based application(Servlet Filter, HandlerInterceptor) is very different from the way a filter is written in a Spring Webflux based application and this post will briefly go over the WebFlux approach to Filters. Approach 1 – WebFilter The first ...

Read More »

Continuous Delivery friendly Maven versions

A Continuous Delivery pipeline requires predictable software and dependency versions. Snapshot versions, which are common in Maven software projects, contradict the motivation behind Continuous Delivery. In order to update snapshot versions to release versions developers usually edit the pom.xml file by hand or via a plugin such as the maven-release-plugin. However, Maven also offers the possibility to define version numbers ...

Read More »

How to map JSON collections using JPA and Hibernate

Introduction The open-source hibernate-types project allows you to map Java objects or Jackson JsonNode as JPA entity properties. Recently, thanks to our awesome contributors, we added support for type-safe collections to be persisted as JSON as well. In this article, you are going to see how to achieve this goal. Maven dependency First of all, you need to set up ...

Read More »