WYTIWYR : What You Test Is What You Run

I’m fed up with unit testing !

It’s 2012 and my first resolution of the year is to finally tell the truth about testing : unit testing is pretty much useless when your code runs inside a container. How do you unit test an EJB which relies on the container services (i.e transaction, injection, security…) ? Well, you mock the database access, you mock your security layer, you mock your dependencies, you mock your validation layer… to test what ? A bit of business logic. Yes. Unit test is interesting when you have complex business logic to test so you can have quick feedback. Otherwise, it’s a waste of time which doesn’t test your container services. So I’m not saying unit testing is completely useless, I’m saying that integration testing is also to be considered when you run your code inside a Java EE container. Continue reading WYTIWYR : What You Test Is What You Run

O Java EE 6 Application Servers, Where Art Thou?

Nearly two years ago (time flies), when Java EE 6 came out, I wrote a post about application servers where I did some micro benchmarking (basically, startup time). I had plenty of comments and recently I had many people asking for some updates. Witht Java EE 6 booming, with some cloud vendors moving to Java EE 6, it was time to update this microbenchmark and focus on Java EE 6 application servers. BTW, if you want to know what Java EE 6 is, you can check the slides of a presentationI gave a few times.

The benchmark

Same disclaimer as last time : This is not a real benchmark ! so I’ll copy paste the paragraph I wrote last time :

In this test I’m just concerned about the usability of an application server for a developer. The idea is to download it, install it, start it and take some measurements : size of download, ease of installation, size of disk, startup time, size of RAM. Continue reading O Java EE 6 Application Servers, Where Art Thou?

Injection with CDI (Part III)

If you follow this blog you should know that latelly I’ve been writing (and talking) about CDI (Contexts and Dependency Injection). CDI has many aspects to it but until now I’ve focused on how to boostrap CDI in several environments, how to add CDI to an existing Java EE 6 application,  and more recently how to use injection with CDI. Actually this post is the third on CDI Injection : Part I focused on default injection and qualifiers, and Part II on all the possible injection points (field, constructor and setters). In this post I’ll explain producers or “how you can inject anything anywhere in a type safe manner“. Continue reading Injection with CDI (Part III)

Walking through the Java EE 6 implementation maze

I’ve been asked so many times “what are the implementations of such or such specification in Java EE 6 ?” or “what is the reference implementation of such a spec ?“. Because I always forget some (and to be honest, sometimes I don’t even know if a spec has several implementations of not), I’m writing this post to help me (and you) to remember.

So here is a non-exhaustive list of the several Java EE 6 implementations (please leave a comment to add anything to this list) … Continue reading Walking through the Java EE 6 implementation maze

[Debate] – And what about configuration in Java EE 7 ?

How do you configure your enterprise application ? Or to be more precise “what is configuration, what can you configure in Java EE and how can you configure it ?

What is configuration ?

Sometimes your application needs to change parts of its behavior at deployment time. You then need to provide some external configuration for some components. For example, in your development environment you don’t want to use a datasource and instead hit the database with a user & password, in your test environment you lookup for the datasource and use it. If you deploy your application in Europe you need to use the Euro as the current currency and if you deploy it in the US you need dollars… Continue reading [Debate] – And what about configuration in Java EE 7 ?

To inject or not to inject: CDI is the question

Two weeks ago I did a little tour around several JUGs and conferences to talk about dependency injections with CDI. The final goal of this road movie was to end up at GeeCon in Krakow. It was my second time at GeeCon and I have to say that this conference is like good wine : getting better with age. This community based conference is on its third edition and attracts people through out central and eastern Europe. Plenty of good speakers, nice location, skilled attendees… and a lot of fun (GeeCon organizers are party addicts). So make sure you mark this conference into your agenda for next year…. Continue reading To inject or not to inject: CDI is the question

Injection with CDI (Part II)

This is the second post based on pure CDI Injection (see Part I) after having talked about how to bootstrap CDI in several environments and how to add CDI to an existing Java EE 6 application. In this post I quickly want to show the different injection points in CDI : field, constructor and setter. To illustrate these different injection points I’ll use a subset of the previous example : a servlet injecting an ISBN generator POJOContinue reading Injection with CDI (Part II)

A week in central Europe… with CDI

I haven’t talked much lately at conferences or JUGs. The last one was Devoxx in November 2010 and I have been quite ever since (working on some other plans ;o) But it’s time to do a bit of touring again. This time it will be Central Europe and the topic with injection in CDI. The presentation of the talk is To inject or not to inject: CDI is the question and the description roughly is :

After a quick introduction of CDI (Contexts and Dependency Injection) I will concentrate on dependency injection and the type-safe approach on injection in CDI. If you are fed up of using String based configuration, come to this talk and have a type-safe journey on CDI.

How come I am touring again ? Everything started with an invitation from my friends at GeeCon. I discovered GeeCon in 2009. It was the first edition of this conference in Cracow (Poland) created by the local user group. Continue reading A week in central Europe… with CDI

Formation Java EE 6 en juin à Paris

XebiaVos avez un nouveau projet dans les tuyaux ? Vous vous questionnez sur les frameworks à choisir ? Vous hésitez à utiliser votre framework printanier à base d’XML et de complexité ? Vous voulez migrer votre application vers un standard ? Vous détestez les EJBs ? J’ai ce qu’il vous faut : une formation de 3 jours autour de Java EE 6 intitulée Architectures d’aujourd’hui avec Java EE 6.
Continue reading Formation Java EE 6 en juin à Paris

Injection with CDI (Part I)

After writing a post about how to bootstrap CDI in your environment and giving you some tips about how to incorporate CDI in an existing Java EE 6 application, I want to talk about injection. Yes, pure injection or how to inject a bean into another one. As you’ll see in this series of three articles (Part II), many different cases can happen. Let’s start with a simple one : a straight forward injection.

Default injection

The simplest possible injection case is… simple. You have something, and you inject something into it. Why am I using the word something ? Because until Java EE 5 we could only inject resources (EntityManager, Datasource, JMS destinations and factories…) into certain components (EJBs and Servlets). With CDI, you can inject nearly anything into anything else. Continue reading Injection with CDI (Part I)

Java EE 7 – I have a (few) dream(s)

If you haven’t used your RSS feed reader lately, you might have missed that Java EE 7 is starting to kick off : JPA 2.1 (JSR 338) and JAX-RS 2.0 (JSR 339) have been voted, Robert Chinnici has talked about it, some conferences have mentioned it… Java EE 7 will happen and quite quickly (Q4 2012). The main focus is the cloud. I will not talk here about the cloud, I’ll talk about everything else (well, not everything ;o)

Java EE 7 is an umbrella specification, meaning it’s made of several specifications. Its goal is to give the other JSRs a common target (here, the cloud) and to make sure these specifications interact well with each other. The Java EE 7 expert group is not responsible for all the JSRs, just the umbrella. That means if the Java EE 7 expert group wants to add something new to the platform (eg. it would be nice to have batch processing into the platform) it will not do it : it will rely on some other spec (i.e. someone else) to specify it and to interact well with the other specs. Continue reading Java EE 7 – I have a (few) dream(s)

Adding CDI to an existing Java EE 6 application

In my previous post I’ve shown you how to bootstrap CDI in several environments (GlassFish, Tomcat, Jetty, Java SE). So now let’s go a bit further and use it in real code. As its name states, CDI (Contexts and Dependency Injection) is also about Dependency Injection, so let’s focus on just this feature for now. I will not define what DI (Dependency Injection) is. If you don’t know I’ll leave you to check the definition, the origins of this pattern and even a book that covers it all. Continue reading Adding CDI to an existing Java EE 6 application

Bootstrapping CDI in several environments

I feel like writing some posts about CDI (Contexts and Dependency Injection). So this is the first one of a series of x posts (0<x<10). I will not go through the entire history of CDI (formerly called Web Beans, splitted in two JSRs… and so on), but will try to give you information on how to use it in different environments, explain you injection, context management, scoping, decorators and so on. So you can think of this series of posts as a humble step by step CDI tutorial. You can also read the very good documentation on the JBoss website (where I got some help and inspiration).
Continue reading Bootstrapping CDI in several environments

Séance de dédicace groupée

Vous l’avez certainement lu dans tous les magasines, la rentrée littéraire 2010 ce n’est ni Michel Houellebecq ni Amélie Nothomb, mais bel et bien la seconde édition de Java EE 6 (aux éditions Apress). Pour fêter cet évènement inter galactique, je m’associe à Emmanuel Bernard (Hibernate Search in Action aux éditions Manning) et Arnaud Héritier (Maven aux éditions Pearson) pour une séance de dédicace groupée à la librairie Le Monde en Tique. Vous aurez ainsi l’honneur et le privilège de rencontrer vos idoles, d’acheter leur superbe ouvrage, de vous les faire dédicacer, de boire un verre et de papoter de tout et de rien. Continue reading Séance de dédicace groupée

I don’t know anything about Silverlight nor .Net

I haven’t blogged for quite a long time. That’s not because I am lazy (well, I took 4 weeks of holidays) or I have nothing to say (titles you could have read in this blog “the rise of Java EE 6”, “the lightweight container strikes back”, “in EJB we trust” or “god save CDI”). No, I was busy finishing the second edition of Beginning Java EE 6 with GlassFish v3.

This second edition has many updates. I’ve updated all the tools of course (GlassFish 3.0.1, Derby 10.6, JDK 1.6.0_20…) but also added extra sections (on JPA, EJB, JSF & JAX-RS) as well as taking into account readers’ feedback. I would like to thank everybody who read the first edition and sent me feedback on Get Satisfaction. That allowed me to correct some mistakes or clarify some concepts. If you get the book, remember to download the code of the examples from Kenai. I’ve also updated lots of code, improved javadoc and added some readme.txt files.
Continue reading I don’t know anything about Silverlight nor .Net

Java EE 6 ? Excuse my French !

It’s been a long time since I haven’t blogged about what I am doing on evenings and week-ends. For people who think that I watch TV and have BBQs on Saturdays, I have to tell you that I don’t have any TV (it’s been over 20 years now) and I don’t have a garden to cook my burgers. No, I’ve spent my spare time updating my Java EE 6 book.

In this second edition I have updated the content and added new sections. When the first version of the book got out it was in June 2009 and Java EE 6 hadn’t been released yet (December 2009). So there were some topics that I didn’t cover because they were not completely finished (like the Criteria API in JPA 2.0). I’ve also updated the frameworks (GlassFish 3.0.1) and the code so it’s more accurate. The book is planned to be published in September 2010. As always there is a full list of people I need to thank for this second edition. Writing or updating a book is hard work and comfort is always needed. Continue reading Java EE 6 ? Excuse my French !

Bean Validation with JPA 1.0

For those of you who still don’t know Bean Validation, you should check the JSR 303 and the documentation of the reference implementation Hibernate Validator. In fact, like many other JSRs, Hibernate Validator existed on its own for quite a long time as an open source project (until version 3.1.x) and then got specified under the JSR 303 and became the reference implementation from its … Continue reading Bean Validation with JPA 1.0

O Application Servers, Where Art Thou?

With Java EE 6 and GlassFish v3 out, it is time to take a little break and look at the application server world. J2EE 1.2 was created in 1999, that’s 10 years ago. The application server market at the time was completely different of the one today. There was Weblogic and Websphere, other proprietary application servers (not following J2EE) and no open source application server. … Continue reading O Application Servers, Where Art Thou?

Mapping and querying a list of primitive types with JPA 2.0

Sometimes you just want to map a list of primitive types. For example, a Book entity has a list of tags and tags are just strings. So you want to do the following : [sourcecode language=”java”] @Entity public class Book { @Id @GeneratedValue private Long id; private String title; private Float price; private String description; private String isbn; private Integer nbOfPage; private List<String> tags = … Continue reading Mapping and querying a list of primitive types with JPA 2.0

Because I always forget how to use maven-ear-plugin

Sometimes you write a blog to express an idea, to ask some feedback from the community, to share a very nice trick… or because you always forget something and want to write it down so you can remember later on. That’s the reason of this post. I never remember how to use the maven-ear-plugin, so I’m writing it down. There is something funny with Maven … Continue reading Because I always forget how to use maven-ear-plugin

Are students getting brainwashed to become project managers ?

As we all know, the percentage of IT projects that succeed is very low, and this post doesn’t have the pretension to explain you why. The reasons are multiple and complex. But there is one that we all know about and live on our day to day jobs : IT projects are mostly made of junior developers and tons of unexperienced managers. Well, at least … Continue reading Are students getting brainwashed to become project managers ?

An interview about me, Java EE 6, the JUG, the JCP and some Jazz

A few weeks ago, Alexis Moussine-Pouchkine asked me for an interview. My book has been out for a couple of month now, Java EE 6 is getting hot, GlassFish V3 is closed to final, the Paris JUG is doing well, I’ve recently been nominated Java Champion, JSR 299 and 330 are working hand in hand, the Cast Codeurs podcast is a success, summer and vacations … Continue reading An interview about me, Java EE 6, the JUG, the JCP and some Jazz