Home » Tag Archives: JAX-RS

Tag Archives: JAX-RS

The Hypermedia APIs support in JAX-RS and OpenAPI: a long way to go

Sooner or later, most of the developers who actively work on REST(ful) web services and APIs stumble upon this truly extraterrestrial thing called HATEOAS: Hypertext As The Engine Of Application State. The curiosity of what HATEOAS is and how it relates to REST would eventually lead to discovery of the Richardson Maturity Model which demystifies the industry definitions of REST ...

Read More »

A configurable JAX-RS ExceptionMapper with MicroProfile Config

java-interview-questions-answers

When you create REST services with JAX-RS, you typically either return nothing (so HTTP 201/2/4 etc) or some data, potentially in JSON format (so HTTP 200), or some Exception / Error (so HTTP 4xx or 5xx). We usually translate a Runtime Exception into some HTTP 5xx and a Checked Exception into some 4xx. Because we want to keep our boundary ...

Read More »

Speed Up Services With Reactive API in Java EE 8

java-interview-questions-answers

Services can often be optimized with asynchronous processing even without changing their behavior towards the outside world. The reason why some services aren’t efficient is that they need to wait for other services to provide a result to continue further. Let’s look how to call external REST services without waiting for them and also do multiple parallel calls independently and ...

Read More »

Java EE MVC: Handling form validation

java-interview-questions-answers

In this post we will have a look on form validation in Java EE MVC. Java EE MVC integrates with the Java Bean Validation API (JSR 303) which makes adding validation constraints pretty easy. Validation using the JAX-RS way Assume we have a small html form that can be used to send contact messages. To represent the form data we ...

Read More »

JAX-RS Tutorial with Jersey for RESTful Web Services

java-interview-questions-answers

In today’s world data plays a very important role. With so many applications using various types of data for different operations, the most important aspect is communication between applications. Data sharing becomes easy between application when they can communicate. It’s like an application running in Asia is providing data to an application running in Europe or vice versa. How is ...

Read More »

Run away from ‘null’ checks feast: doing PATCH properly with JSON Patch

Today we are going to have a conversation about REST(ful) services and APIs, more precisely, around one peculiar subject many experienced developers are struggling with. To put things into perspective, we are going to talk about web APIs, where the REST(ful) principles adhere to HTTP protocol and heavily exploit the semantics of HTTP methods and (usually but not necessarily) use ...

Read More »

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 »