Java EE: Setting up and Testing Form-Based JDBC Authentication with Arquillian and Maven

Especially when it comes to testing, setting up a decent environment for a secured Java EE web application isn’t always an easy thing to do. In the following tutorial I’d like to demonstrate how to create a secured web application using form-based authentication and a JDBC realm to fetch users and roles and how to run the application in an embedded container for testing and development. Additionally I’d like to show how to write and run integration tests to verify the security setup using a setup of Maven, Embedded GlassFish, Arquillian, jUnit and rest-assured. ...

December 21, 2014 · 14 min · 2822 words · Micha Kops

Creating different Websocket Chat Clients in Java

Having written two articles about different websocket based chat server implementations in Java, I was recently asked how an implementation of the client side would look like in Java. That’s why I added this article to demonstrate how to create a websocket chat client applications within a few steps with the Java API for Websocket. In the following tutorial, we’re going to write a text-based chat client for the console first and afterwards we’re going to program a chat client with a graphical user interface, implemented in JavaFX. ...

November 9, 2014 · 10 min · 1937 words · Micha Kops

Java EE 7 JMX Reports with Yammer Metrics

There are several ways to aggregate and report application performance indicators in a Java application. One common way here is to use Java Management Extensions (JMX) and MBeans. The Yammer Metrics Library eases this task for us and simplifies the aggregation of different reports. In the following tutorial, we’re going to set up a full Java EE 7 web application by the help of Maven archetypes and we’re running the application on WildFly application server that is downloaded and configured completely by the WildFly Maven Plugin. ...

August 26, 2014 · 10 min · 2117 words · Micha Kops

Java EE: Logging User Interaction the Aspect-Oriented Way using Interceptors

Using dependency injection and aspect-oriented mechanisms like interceptors allow us to separate cross-cutting-concerns in our Java enterprise application, to control global aspects of our application and to avoid boilerplate code. In the following short tutorial we’re going to create an aspect-oriented logger to protocol the initiating user, class and method called and the parameters passed to the method and finally we’re adding this interceptor to a sample RESTful web-service by adding a simple annotation. ...

May 26, 2014 · 6 min · 1275 words · Micha Kops

JAX-RS 2.0 REST Client Features by Example

JAX-RS 2.0 aka JSR 339 not also specifies the API to build up a RESTful webservice but also enhances the client side API to ease up the process of writing a client for a REST service. In the following tutorial we’re building up a client for a ready-to-play REST service and explore the different new options e.g. how to handle requests in a synchronous or asynchronous way, how to add callback handlers for a request, how to specify invocation targets to build up requests for a later execution or how to filter the client-server communication using client request filters and client response filters. ...

December 30, 2013 · 10 min · 1941 words · Micha Kops

Creating a Chat Application using Java EE 7, Websockets and GlassFish 4

Java EE 7 is out now and so I was curious to play around with the new specifications and APIs from in this technology stack. That’s why I didn’t hesitate to add yet another websocket-chat tutorial to the existing ones on the internet in favour of gathering some experience with this technology and a possible integration using a GlassFish 4 server, the new Java API for JSON Processing for data serialization combined with custom websocket encoders/decoders and finally adding some Bootstrap and jQuery on the client side. ...

August 13, 2013 · 8 min · 1591 words · Micha Kops

Continuous Deployment using GlassFish, Jenkins, Maven and Git

Recently I needed a quick solution to deploy a Java EE 6 web application on a GlassFish instance automatically and subsequent to a successful build of the project on the integration server. It took only a few steps using Jenkins, Maven and the Cargo plugin and I’d like to share this quick solution with you here. Prerequisites We need the following software installed and configured: Git Jenkins / Hudson + Git Plugin installed Maven 3 GlassFish 3.1 JDK 7 ...

May 29, 2013 · 6 min · 1202 words · Micha Kops

Easy Database Migrations using Flyway, Java EE 6 and GlassFish

Database migrations often are a necessity in the application development and maintenance life-cycle. Whenever we need to apply changes to the database structure, insert new data fragments and in doing so want to be sure that this all happens with some control and versioning. The following tutorial shows how implement this for a simple Java EE 6 web application to be run on a GlassFish application server in a few quick steps using the Flyway framework, an eager initialized Singleton EJB and some Maven wiring. ...

April 28, 2013 · 9 min · 1742 words · Micha Kops

Task Scheduling in Java EE 6 on GlassFish using the Timer Service

Creating cronjobs or scheduled service executions is made really easy in Java EE 6. Scheduled tasks may be created in a programmatic style or simply by adding some annotations to an EJB. In the following tutorial we’re creating some simple scheduled tasks and let them run on an embedded GlassFish instance using the Maven Embedded GlassFish plugin.. Java EE 6 Maven Project from Archetype First of all we’re creating a new maven-ized project using one of the appropriate jee6 Maven archetypes ...

June 22, 2012 · 5 min · 956 words · Micha Kops

Arquillian Tutorial: Writing Java EE 6 Integration Tests and more

Now that the long awaited stable version of the Arquillian framework is released I wanted to demonstrate some interesting features of this framework that really eases writing and running of integration tests for Java EE 6 applications in many different ways. In the following tutorial we are going to create some real-world examples using Enterprise JavaBeans, Contexts and Dependency Injection, the Java Persistence API and we’re finally running Drone/Selenium tests against a JEE Web Application that is using Java Server Faces. ...

April 26, 2012 · 8 min · 1576 words · Micha Kops