Category Archives: Java

Unit Testing Spring MVC JSON data-binding with JUnit and Mockito

In this post, I’ll show you how to write clean and easy to understand JUnit test for any Spring Controller that has JSON databinding through the @RequestBody annotation with only JUnit and Mockito.

Also posted in Spring | Leave a comment

Generating PDF from XHTML and CSS2 template with Flying Saucer 9.0.4

In this post, I will share a small utility for creating PDF files from a template file written in XHTML and CSS 2.1. The template file is set up with a stylesheet that handles margins, page breaks and running top content. This is a complete example showing how to use the Flying Saucer 9.0.4 framework (based […]

Also posted in Web | Tagged , | Leave a comment

Introduction to JDK8, Lambdas and Functional Interfaces

In this blog, I will give you a quick introduction to the upcoming version of Java, showing you simple examples of how to use the most important feature in JDK8; lambda expressions.

Posted in Java | Tagged | Leave a comment

How-to: Using Tiles 2.2.2 with Spring MVC 3.x

In this short tutorial, I’ll explain you how to use the Tiles 2.2.2 templating along with Spring MVC 3.x.

Also posted in Spring, Web | Tagged , | Leave a comment

What to do when SyntaxHighlighter doesnt work on Ajax loaded pages

Recently when working on a feature for syntax highligting using SyntaxHighlighter library, I noticed that pages loaded through Ajax was not higlighted. Here’s how I solved it.

Also posted in Web | Tagged , , | Leave a comment

Tip: How to generically sort unknown objects by their nested properties

In this post, I’ll show you how to sort an array of unknown objects by their nested properties. The objects doesnt need to implement the Comparable interface.

Posted in Java | Tagged | Leave a comment

Tip: How to instantiate a generic Java object with arguments

While writing a text-based database, I fell into the following problem: How do I convert a column of String’s into any wrapper type of my choice? The solution I found is a generic instantiation with a single String argument in its constructor. 

Posted in Java | Leave a comment

Unit testing your Spring JMS implementation

JMS is a J2EE integration pattern that’s commonly used in Enterprise applicatons, which enables enterprises to send and receive business data through a distributed cross-platform communication protocol.  Spring JMS is a framework that simplifies the use of the JMS API. Without going into more detail, however, I’ll present one possible solution on how you can unit test your Spring JMS implementations.

Posted in Java | Tagged , , | Leave a comment

Installing and running Apache MyFaces 1.2 with RichFaces 3.3

In an attemt at learning Java Server Faces, I thought that testing out an example application would be a good starting point. After reading about pros and cons related to the many different implementations of JSF, I ended up with the following ingredients:

Also posted in Web | Tagged , | Leave a comment

Handling multiple resource connections in Websphere Application Server

 I have been working on migrating a EJB2 application from Websphere 6.1 to Websphere 7 and upon application startup, I got some strange looking error messages:

Posted in Java | Tagged | Leave a comment