Customizing Bean Validation in Spring

Here’s an example of how to customize the javax.validation.Validator instance in Spring 5.  Validator is the Java API for bean validation that was introduced in the JSR-303 specification.  Hibernate Validator is bundled with Spring Boot 2, and is the de facto reference implementation for bean validation. Why would you need to do something like this? Read More …

Spring Boot and CORS

Spring Boot has had support for enabling CORS in REST controllers since version 1.3.  The @CrossOrigin annotation is straightforward to apply at the method or type level to enable cross origin requests: Testing with cURL cURL is an obvious choice for testing CORS with Spring Boot RESTful API endpoints. results in the following output: Changing Read More …

MySQL Disaster Recovery

Background You’ve accidentally deleted some or all of the rows in a table, or even dropped a schema object altogether, in a production MySQL database. You need to recover the database to the point right before the accidental statements (DML or DDL) were executed, in essence undoing them. What You’ll Need A recent backup file Read More …

Algorithm Problem: Houses

This is an interesting maximization problem that can be solved efficiently, in O(n) time, using dynamic programming. You’re given a list of houses, each with a money value assigned to it. The problem is to choose houses from the list so as to maximize the total money from them, but no two houses chosen can Read More …

Multihomed Hosts and Java RMI

It can be challenging to get Java RMI communication working right between components on multihomed hosts. To see why, it’s important to understand how RMI determines the server hostname, which ultimately ends up being passed around in RMI stubs. If a client uses an RMI stub to make a remote method call and can’t connect Read More …

XPath for Namespaces

Today I was confronted with the problem of obtaining a list of all namespace attributes for a given XML document. I found that it’s possible to achieve this quickly using the XPath expression //namespace::*, which leverages the namespace axis defined in the XPath 1.0 specification. I’m using Xalan bundled with Sun JDK 1.6, and so Read More …

Downloading JDK 1.5?

It’s more difficult to download Sun’s JDK 1.5 now (version 1.5.0_22 to be precise as I write this) that the company has officially announced its end-of-life.  Downloading it by following the normal path on Sun’s website will land you at a registration form explaining that “Sun offers Java SE for Business, a service offering that provides Read More …