Java Weekly #5: Metaspace, Server-Sent Events, Java EE 8 drafts and more...


If you like to learn more about the removal of PermGen and the introduction of Metaspace in Java 8, you should have a look at Where Has the Java PermGen Gone? by Monica Beckwith. She wrote a great post about problems with the old PermGen and how they were solved with the new Metaspace.

Java EE

Server-Sent Events (SSE) were introduced with HTML 5 and enable the server to push data via HTTP to the client. Shing Wai Chan shows in his post Server-Sent Events with Async Servlet By Example how you can implement SSE by only using the Servlet API.

Antonio Goncalves wrote an interesting article about integration testing. He wants to execute the integration tests of his web application only, if it is successfully deployed on the JBoss application server. Otherwise the tests shall be skipped. He describes in his post Your tests assume that JBoss is up and running how this can be achieved by using JUnit assumptions and the JBoss HTTP management API.

Ed Burns posted a draft proposal for JavaServer Faces 2.3. One of the main categories of new features mentioned in the draft is "Community driven improvements". These will probably be fixes to issues listed in the JSF issues tracker. Arjan Tijms posted with JSF 2.3 wish list part I - Components the first article of his wishlist series for community driven improvements.

The draft proposal for the Servlet 4 JSR was posted, last week. If you want to learn more about it, have a look at this great summary post by David Delabassee: Servlet 4.0


Don't repeat Yourself (DRY) is one of the key principles of a good software design. The post Keeping things DRY: Method overloading shows how to implement a rich and DRY API in Java and discusses the reasons for doing it.

This and that

Mhamrah describes in his article On the Balance of Speed and Quality how to handle a common problem of our day to day work. We need to provide a high quality solution as quick as possible. And as we all know, time pressure and quality are no good friends. Mhamrah explains how to use two questions to bring speed and quality into the right balance.

Upcoming events

Samir Talwan will present his talk Highly Strung: Understanding your Type System at the virtual JUG at 4pm UTC on Monday, 28th July. Join the live stream if you want to learn how to improve your code by using the type system.


That were the most interesting Java related resources I found this week. I hope you find them useful.

If you think I missed something, please post a comment with the link. I will check it and include it in the next issue of Java Weekly.

Java Weekly #4: PicketLink and DeltaSpike, Batch API, JMS 2.1 and more...

Java EE

Shane Bryzak wrote a great article on how to use PicketLink and Apache DeltaSpike to secure your Java EE application. The combination of these two frameworks is really powerful. It allows you to add security to your application by implementing only one annotation and one method.

The Batch 1.0 API does not offer any solution to schedule a batch operation in Java EE. But there is no need for it, as Arun Gupta shows in his Tech Tip #36. The Java EE plattform already offers 3 different ways to schedule a batch operation.

If you want to learn more about the Java EE Concurrency API, you should have a look at the Java EE Concurrency API Tutorial by Francesco Marchioni. He created a detailed description on how to process parallel tasks on a Java EE application server. This is really a great resource if you want to learn more about Java EE Concurrency.

The new and updated Java EE 8 APIs are taking shape during the last days. If you want to know what might be part of JMS 2.1, you should have a look at It's time to begin JMS 2.1! by David Delabassee. He collected several information on the draft proposal for JMS 2.1.


Most of you might have read about or experienced some drawbacks of the Java 8. Alex Zhitnitsky created his list of 6 reasons why he thinks you should not switch to Java 8. He combined several great articles with his personal opinion to create a good write-up of Java 8. You should read at least some of the collected articles while switching to Java 8. So this is a good point to start.

Breandan Considine posted the Java Annotated Monthly – June 2014 on the JetBrains blog. If you are looking for an extensive Java Monthly, you find it there. He created a massive collection of great Java resources created during the last month. You should definitely have a look.

This and that

If you missed the talk Testing and Refactoring Legacy Code by Sandro Mancuso at the vJUG, you can now watch it on demand. You should definitely watch it if you have to deal with legacy code (are there any developers who don't have to?).

Roberto Cortez wrote a nice article on Five Ways to Not Suck at Being a Java Freelancer. He describes 5 important things you need to take care off as a freelancer. This is a good read, if you want to relax with a non-tech article.

The HornetQ Team offered to handover their codebase to the ActiveMQ project: HornetQ and ActiveMQ: Messaging - the next generation
This sounds like an interesting idea with lots of potential for the future. ActiveMQ and HornetQ are both great messaging solutions on its own. So we can expect a lot, if they join their codebase.
What do you think about it?


That were the most interesting Java related resources I found this week. I hope you find them useful.

If you liked it and don't want to miss any future Java Weeklies, subscribe to the blog and follow me on twitter..

If you think I missed something, please post a comment with the link. I will check it and include it in the next issue of Java Weekly.

Java Weekly #3: Microservices, Java 8 features, upcoming events and more...


The article Tired of Null Pointer Exceptions? Consider Using Java SE 8's Optional! by Raoul-Gabriel Urma gives an extensive description about how to use Optional to improve your API and avoid NullPointerExceptions.

Oleg Shelajev wrote an interesting article about the unpredictability of parallel streams. The stream API is one of the major features introduced with Java 8 and it seems to be easy and powerful. But as Oleg describes in his article, it can influence the performance of your application in an unpredictable way.

Java EE

Maven archetypes are a quick and easy way to setup a Maven project and immediately start with the implementation. But so far there was no archetype to create a Java EE 7 project with Arquillian dependencies and profiles (at least as far as I know...). If you have used Arquillian to test your application, you know that setting up the profiles for different application servers is always some annoying (copy & paste) work.
This has changed since Arun Gupta introduced a Maven Archetype for Java EE 7 projects with Arquillian profiles on his blog. The archetype provides Java EE 7 dependencies and creates a managed and a remote profile for Wildfly and GlassFish.

The GlassFish team announced FishCAT, the GlassFish Community Acceptance Testing program. The goal of this program is to improve the quality of the GlassFish application server with the help of the community. If you are using GlassFish (4.0.1), you should definitely have a look at this program.


Bilgin Ibryam explains his 10 best practices for creating microservices in his article on jaxenter. If you want to know how Apache Camel helps you to create an application based on microservices, you should have a look at this article.

And if you want to read more about microservices, have a look at Matt Stines Microservices Reading List. He has curated an extensive list of currently 47 resources about microservices.


Geekout 2014 took place on June 12-13 in Tallinn Estonia and they presented 15 talks within these two days. 2 day conferences with 15 talks is not unusual, but they did something extraordinary. They recorded all talks and put them on their website for free (only 13 at the moment, but the 2 missing shall follow):

If you like to watch even more conference talks, have a look at the GeeCon Vimeo Channel. You can find there a few talks of their GeeCon 2014 conference.


Heather VanCura wrote a June JSR Updates post at the Oracle blog.


I recommended the gradle multi-part tutorial by Petri Kainulainen already in Java Weekly #1. Until then he published the first two parts where he described how to setup gradle and how to create a simple java project. Now he has published the third part in which he describes how to define the project dependencies:

Upcoming Events

There are three interesting online events this week:

Jason Greene will present What's new in WildFly 8? on Tuesday 5pm UTC at the JBUG: Worldwide. Join the YouTube live stream, if you want to get an overview of the current version of the application server.

On Wednesday 4pm UTC, Sandro Mancuso will talk about Testing and Refactoring Legacy Code at the vJUG. This talk will also be streamed on YouTube.

Oracle's Virtual Technology Summit is taking place this week and next week. They present 3 sessions and run the event 3 times in different time zones, so have a look at their website and decides which date and time fits your schedule.


That were the most interesting Java related resources I found this week. I hope you find them useful.

If you liked it, please subscribe to the blog and follow me on twitter to not miss any Java Weekly.

If you think I missed something, please post a comment with the link. I will check it and include it in the next issue of Java Weekly.

Java Weekly #2: JPA 2.1, Java8, JSR 351, Eclipse Luna and more...

Java EE

Steven Gertiser showed a great example on how to use a JPA Type Converter to persist the new Java8 DateTime classes. This example shows again how powerful the type converter feature is. You only need a few lines of code to define how a class gets persisted to the database.
If you like to read more about Type Converter and other new features of JPA 2.1, have a look at my JPA 2.1 related posts.

Normally, I try to ignore the Spring vs. Java EE discussion, but I found a good posting by Nmpallas this week. He is a long time Java EE developer and gave Spring a try for a recent project. His main reason was, that an application server offers much more features than he needed. But after some time, he decided to migrate the application to Wildfly 8.0.0. Read about his reasons and what he thinks about the standard Spring arguments in: It’s not Spring anymore is the summer of JEE7, ready riding the wave?

Java 8

Java 8 introduced the two default methods forEach(Consumer action) and spliterator() to the Iterable interface. While this looks good in the first place, Stephen Colebourne is not as happy with it. He describes in his blog why this change reduced the number of use cases of the Iterable interface: Java 8 - Iterable woes
I do not see a huge issue in this change. But what do you think? Is this really a drawback of the new Iterable interface?

Java Identity API (JSR 351)

Abhishek Gupta had a closer look at the Java Identity API. The primary goals of this JSR are to define a representation for an Identity in Java and to provide a high level programming model and API to interact with identity/attribute repositories. This JSR is still work in progress and Abhishek gives an overview of the current state.


OK, Javadoc is not new and not the most interesting part of Java. But I found two interesting links on twitter this week. Have a look at these articles, if you like to bring your Javadoc to the next level.
Michael Scharhag wrote a tutorial on how to use Markdown to write your Javadoc comments. And if you prefer to use AsciiDoc, you should have a look at this post by John Ericksen: Write Javadocs in AsciiDoc with Asciidoclet. write it.
Both approaches provide you the option to write a documentation and not just a short comment in your Javadoc comment.


Eclipse Luna was released this week and it is packed with new features.
Ian Bull created a very detailed description of his 10 favorite new features in Eclipse Luna. Some of them are RCP and RAP improvements, Sirius, SnipMatch, Split Editors and of course Java 8 Support.

The JBoss Tools team released with 4.2.0.Beta2 a new version based on Eclipse Luna. You can find a description of the new features in Max Andersens Announcement and the JBoss Tools documentation.
And if you like to provide some feedback and influence the development of JBoss Tools, have a look at the JBoss Tools Community Acceptance Test.

If you prefer to use NetBeans, you are also asked for feedback. Have a look at the NetBeans IDE 8.0 Satisfaction Survey. It contains only 12 questions and is quick to answer.

This and that...

Eric Jiang wrote a great post about NodeJS and why not everything is as perfect as it seems in other articles. If you like to read why performance, concurrency and leveraging existing JavaScript expertise is not as beneficial as it seems, have a look at: The emperor’s new clothes were built with Node.js

Making salaries a secret is common in most of the companies. Jappreet Sethi created a nice write up why salaries should not be a secret anymore and how this improves the employees trust in the company. 
I do not want to say too much about this. But dear companies, if you want your (good) employees to stay with you, make sure that they trust in you and get a fair salary.


That were the most interesting Java related resources I found this week. I hope you find them useful.

If you read this far, you should subscribe to the blog and follow me on twitter to not miss the next issue of Java Weekly.

If you think I missed something, please post a comment with the link. I will check it and include it in the next issue of Java Weekly.

Java EE Pitfalls #1: Ignore the default lock of a @Singleton

EJB Singleton Beans were introduced by the EJB 3.1 specification and are often used to store cached data. This means, we try to improve the performance of our application by using a Singleton. In general, this works quite well. Especially if there are not too many calls in parallel. But it changes if we ignore the default lock and the number of parallel calls increases.

Java Weekly #1: CDI, Java8, Bean Validation and more...


Are you familiar with CDI events? Really?
Well, then you might skip the beginning of the article You think you know everything about CDI events… Think again! by Antoine Sabot-Durand. He gives a great overview about how CDI events work and their (current) drawbacks. And he gives a small sneak peak at the changes we can expect with CDI 2.0.
This is by far the best overview about CDI events I have read so far. Everyone who is using them, should have a look at it.

The Apache DeltaSpike team released version 1.0 this week. You can find the release notes here and a short overview about the different modules in this posting by Rafael Benevides.
DeltaSpike looks really interesting and seems to provide several features I have missed or found quite complicated to implement. I have never used it so far, but I am planning to change that. If anyone of you has some real world experience with it, please write a comment. I love to hear about it.

Java 8

Oleg Shelajev takes a critical look at the usage of default methods introduced with Java 8. His main point is, that the usage of default methods can make it really difficult to understand your code. If you combine default methods of different interfaces with inheritance, it can become really difficult to find which method implementation will be executed. Therefore, you should think carefully before using default methods everywhere. Quiet often you can use inheritance to get to the same result.
I really liked his post. It is tempting to use new features as often as possible. But we always need to be aware of possible drawbacks. And a loss of readability and an increased complexity of our code can be a massive drawback if you or one of your colleagues has to change or analyze the code.

If you are looking for more information and learning resources about Java 8, you should have a look at Java 8 Friday: The Best Java 8 Resources – Your Weekend is Booked over at the jooq blog.

Bean Validation

Emmanuel Bernard gives with his posting Blah vs Bean Validation: you missed the point like Mars Climate Orbiter a nice response to a post by Julien Tournay. Julien compared the Play Unified Validation API with Bean Validation and prefered the Scala solution for several reasons.
As expected, Emmanuel did not agree with it :) His response is fun to read and very informative. You should not miss it!


If you are new to gradle, you should have a look at this multi-part tutorial by Petri Kainulainen:

He shows how to setup gradle in the first part and how to use it to create a simple java project in the second part of his tutorial.

This and that...

OK, that has to be enough technical stuff for this week. But I also found two not so technical resources I want to share with you. Have a look:

Erik Dietrich tells in The Zen of Rejection: Let Companies Go In That Other Direction a great story about his experience with job interviews and the bad feelings after getting rejected. This is really a great read and he describes a nice way to get your head up again after being rejected.

You should definitely have a look at the slideshare presentation Death by PowerPoint - Redesigned by Ikedinekpere Chiz before you prepare your next presentation. These slides are impressive and tell you how to create a better presentation for your next talk or meeting.


That were the most interesting resources I found during this week. I hope you find them useful.

If you think I missed something, please post a comment with the link. I will check it and include it in the next edition of my Java Weekly.

Testing with Aliens: How to test a JPA type converter with Arquillian

This post was written together with +Aslak Knutsen (@aslakknutsen).

JPA type converters provide an easy way to define how an entity attribute gets persisted to the database. You can use them to implement lots of different features, e.g. to encrypt your data as I showed in a previous post: How to use a JPA Type Converter to encrypt your data
But writing the type converter is not enough. We also need to make sure, that it is working correctly.

In general, there are two ways to test a type converter. We could write a unit test to check, if the conversion works correctly. But a unit test performs a test of the isolated class without putting it into the real execution environment. That means that we will still not know, if the converter works in one of our applications. If everything is set up correctly, the persistence provider will call the converter before writing to and after reading from the database. So we also need to check if the type converter gets called by the persistence provider and if everything works fine under that condition. We need to test the converter inside of the container we want to use for our application.
We will have a look at how this can be done with Arquillian and its persistence extension.