Skip to content

Les critiques du livre Java EE 5

DZone avril 2008

Une fois n'est pas coutume, une revue de presse d'un site anglo-saxon. Un grand emerci à David Sills de l'équipe de JavaLobby qui, connaissant un peu le français, a fait l'effort de livre un ouvrage qui n'est pas écrit dans sa langue de prédilection. De plus, la critique est très bonne.

Un extrait : To be honest, I'd like to have this book in English for newbies in the field! We'd have a lot better applications built, I can say that.


Read More →

Installer l’application sur MySQL


L'application développée pour le livre utilise le serveur GlassFish et la base de données Derby. Pour installer l'application sur la base de données MySQL il faut effectuer quelques changement.

Installez et configurez MySQL

Tout d'abord, il faut installer MySQL 5. Pour cela, rendez-vous sur le site de MySQL et téléchargez la version dédiée à votre plateforme. Démarrez la base de données et connectez vous à celle-ci via l'éditeur (mysql -u root). Il faut ensuite créer la base petstoreDB et la rendre accessible à l'utilisateur dbuser (mot de passe dbpwd).

Read More →

Install the application


The Java EE 5 book enables you to develop an e-commerce application using multiple Java EE 5 specifications. Throughout the chapters you have to develop layer after layer (persistence, session facade, web interface, electronic shopping cart, web services and asynchronous processing) to obtain a web site to sale domestic animals.

Download the code

First of all, you have to downloadthe code of the application.

Directories structure

Uncompress the file that you have just downloaded and you will obtain three principal sub-directories. Those correspond to the various applications:

Read More →

Demo of the Petstore application

In the Java EE 5 book, you will have to develop a web and a swing application that talk to an EJB 3 back end.

In this Flash animation, you'll see how to use the Petstore web application. First It browses the catalog of pets, then logs a user on, who buys a few animals, adds them to my shopping cart, changes some quantities of the shopping cart and then checks out.

In this animation you can see the administration console. It is developed in Swing and used to create/modify/remove items of the catalog as well as having a view on customer and orders.

Read More →

Article: Master the New Persistence Paradigm with JPA

I have to say, I believe in JPA. Being a former BEA consultant, I used entity beans at a very early stage of the spec and was one of the first to do a prototype of entity beans 2.0 for a customer with a beta version of weblogic (6.0 if I still remember back in 2001). I thought that wasn‘t very good (to be polite). We had customers doing so many funny things with entity beans that it couldn‘t be right. The spec was too difficult and customers didn‘t have a clue to use it the right way. And then Hibernate arrived, and now JPA. I believe the JPA spec will be the one in terms of ORM because it‘s inspired by excellent frameworks such as Hibernate or TopLink, uses annotations which gets rid off XML config files and it looks like everybody around the JCP table agreed on it (not like JDO, R.I.P). Of course there are still things to be improved, but for a 1.0 it‘s not bad at all. I‘ve written a first article about JPA (second coming soon) for DevX. It explains the basic mapping annotations, one-to-one relationship, Entity Manager and how to use JPQL. The second is more advanced and deals with inheritance, one-to-many, many-to-many relationships and JPQL. I‘ll let you know when it‘s out. I would like to thank Thierry Balla, David Dewalle, Matthieu Riou and Thomas Verin for reading the articles before they […]

Read More →

Java Black Belt at University

I‘m quite excited. At the CNAM University we’ve decided to try Java Black Belt with our students. The idea is to use JBB to ensure a minimum level of Java within our students. Thanks to John Rizzo (who I met at JavaPolis) and Gonzague Lefere who‘ve setup a temporary server just for our IT department. Our students will have the week of the 5th of february to pass 3 Java Black Belt exams (JSP, Servlet and EJB). We will then get their feedback to see if we will carry on with Java Black Belt or not. Such a test is quite a novelty for the CNAM University. Usually students have to sit an exam at university. In our case, they will do the Java Black Belt tests from home (knowing that they can invite Java friends for diner ;o) But we want to give it a try. And our idea is not really to use Java Black Belt to grade them and therefore make them pass the year or not. It‘s more to know their level of Java so we can start the year with the same kind of students. I would let you know about the feedbacks and our plans to adopt Java Black Belt as an exam tool.

Read More →

Java EE 5 Book – What, When, Who

As I‘ve posted back in september, the book I’ve written uses Java EE 5 to develop a good old PetStore-like application. It’s written in French and will be published by Eyrolles at the end of March or begining of April. It is part of the Les cahiers du programmeur collection (programmer‘s book). This collection is quite pragmatic and focuses on a hands-on approach. The books always start with a presentation of the application to develop, and after, chapter by chapter, add functionnalities and technologies. All that is written in two columns : one for the main subjects, and a smaller one for references, ideas, questions, definitions and so on. Here is the structure of my book: Chapter 1 presents the case study of an e-commerce application inspired by the Sun’s Java PetStore Blueprint. The fictitious company Yaps wants to computerize its activity of selling domestic animals. The application uses a webapp for the customers, a Swing app for the employees and needs to exchange data with external partners. UML, Use Cases Chapter 2 concentrates on the technical and software architecture of the application called Yaps PetStore. This chapter briefly presents the tools and APIs used for the development. Java 5, HTML, XML, Java EE 5, Blueprint, Design Patterns, UML The installation and the configuration of the tools are done in chapter 3. JDK, Ant, GlassFish, Derby, TopLink In Chapter 4 we develop the persistent objects of the application. JPA, Entity […]

Read More →

I’ve been tagged – Six things you don’t know about me

Yes, I‘ve been tagged by Matthieu… a long time ago. I should have blogged back a month ago but because of finishing my book I haven‘t had time to do it. I deserve a penalty for beeing so late. So, here are six things (instead of five) about me that (nearly) nobody knows : Tell me a word and I‘ll sing you a song. I‘m this kind of guy that you have to stop from singing each time you say something. I always find a match between a word and a song (mainly 60‘s and 70‘s music) I‘m passionate about religions (with an ‘s‘). Beeing a complete atheist makes life easier to read any kind of book about any kind of religion. After Java, religious books are the ones I read the most. I know which time it is (+/- 15 minutes). Because of not wearing a watch for so long, I‘ve developped this sense of knowing what the time is… even at night with no sun. I love any kind of art (mainly modern). My wife doesn‘t need to drag me to go and see boring stuff like art exhibition, ballet or abstract theatre play. I hate dogs, well, to be precise I hate people who have dogs. Beleive it or not, I still find a bit of time to play jazz with my band. Now I’m supposed to tag five others. But because I‘ve waited so long, all […]

Read More →

Java EE 5 Book – The End

Today I‘ve uploaded all my Open Office files to Eyrolles FTP server. That’s it, I’ve finished writing my book about Java EE 5. I will blog later about its content. I just want to thank my team of readers : Matthieu Riou, Alexis Midon, Zouheir Cadi and David Dewalle. Thanks guys, you‘ve been a great help. The book will benefit from your comments and expertise. And sorry for making you work so hard on the last weeks. I would also like to thank JetBrains and Visual Paradigm for giving me a free licence of their software. And of course, many thanks to my wife who didn‘t divorce me while I was writing on evenings, nights, early mornings and entire week-ends. I‘ll blog more later. But now, I just want to go out, have some sun, see some real people and enjoy life again.

Read More →

JavaPolis 2006 – Back Home

Well, how to say that in a simple way: JavaPolis 2006 was great. Here are more details. Organisation First of all, the organisation was amazing. JavaPolis is not organised by Sun, BEA, IBM, Oracle… but by the BeJUG (Belgium Java User Group). Guys like you and me who decided 5 years ago to create such an event that became international […]

Read More →

JUnit 4 at Java Polis

At Java Polis I made a quicky (a presentation of 15 minutes) about JUnit 4. I've been using JUnit for quite a while. I've also tried TestNG but never really got into it. In summer 2006 I worked with JUnit 4 at a customer. I've used it quite intensively, that's when I decided to write an article about it (Get Acquainted with the New Advanced Features of JUnit 4). I've proposed a quicky to JavaPolis and it was accepted. Checkout the blog I wrote about it.

If you are interested in this presentation just check the slides.

Read More →

JavaPolis 2006 – Leaving tomorow morning

God, I‘m so involved in finishing writing my book that I’ve completly forgotten talking about JavaPolis. I’m leaving tomorow from Paris in an early train (6:55am) and will present a Quicky about JUnit 4 on Thursday. I‘ve already picked up the sessions I want to attend, mainly JEE, Scripting languages and a bit of JSE. A couple of former BEA colleagues should be there and a few french open source actors too. Hope I will have enough time to attend all the sessions I want and have a couple of beers with them.

Read More →

Writing a book about Java EE 5

A couple of days ago a friend sent me an email saying that I haven‘t blogged for few weeks now. The reason is that I‘m writing a book about Java EE 5 and it‘s taking me a lot of time (after work and in the week-ends). The chapters will roughtly be : * Presentation of Java EE 5 * Presentation of the Architecture of the application to develop * Java Persistent API * Stateless EJB 3.0 * JNDI an remote access with swing client * JSF 1.2 and JSP 2.1 (Unified EL) * Stateful EJB * JMS and MDB * Web Services (with Jaxb 2) It‘s a practical book, not a reference one, so there is only 30/40 pages per chapter with external references to go to. It‘s aimed at experienced java developpers who have had web development experience. I am a JBoss/Hibernate user but unfortunately I had to leave these frameworks because not really Java EE 5 compliant (stil JSP 2 and JSF 1.1). I‘m using Glassfish with Toplink and Derby. I lost a bit of time with this switch but it‘s ok. I didn‘t know Glassfish before and I‘m quite impressed with what they‘ve done. Ok, have to go and I will blog more about what I‘m doing… I should publish an article about Java EE 5. PS : JSF is driving me mad

Read More →

How to unit test CRUD operations

I like to unit test CRUD (Create, Read, Update, Delete) operations for my domain objects as well as find all. I use the same template again and again, it’s quick to do and makes sure that the basic operations work. Here is what I do : * A first find all to get all the objects from the database * Create an object with random values and persist it into the database * Find the created object from the database * Make sure it exists * Make sure it has the right random values * Update the created object with other random values into the database * Find the updated object from the database * Make sure it still exists * Make sure it has the new random values * A second find all makes sure that there is one more object in the database * Delete the object from the database * Find the object from the database * Make sure it doesn’t exist * A third find all makes sure that there is the initial number of objects in the database Here is the (simplified) JUnit code that tests the CRUD operations for an Item. @Test public void testCRUD() throws Exception { // Gets two random numbers Long random = getRandom(); Long updateRandom = getRandom(); // Item is the domain object Item item = new Item(); // The method findAll brings back all the objects from the DB […]

Read More →

HelloWorld with JPA, Hibernate and MySql

I love Hello Worlds. So when I read the blog HelloWorld with JPA, TopLink and MySql I’ve quickly copied/pasted the code, downloaded everyhting and made it work. Good. But because I’m more a Hibernate user, I thought, let’s give it a try with the same example but using Hibernate EntityManager instead of Toplink. So here is the same simple example of standalone java application using Java Persistence API (JPA), Hibernate, and MySql 5. Here is what you have to do : * First, download Hibernate Core 3.2.CR2, Hibernate Annotations 3.2.0 CR1 and Hibernate EntityManager 3.2.0 CR1 * Write the META-INF/persistence.xml file <persistence> <persistence-unit name="hello-world" transaction-type="RESOURCE_LOCAL"> <class></class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="" value="create"/> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test"/> <property name="hibernate.connection.username" value="root"/> <property name="hibernate.connection.password" value=""/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> </properties> </persistence-unit> </persistence> * Use the same Entity class and Main class than the one written in the HelloWorld with JPA, TopLink and MySql blog * Start MySQL * Compile and run the project with the folowing classpath java cp ..\classes;%LIB%\ejb3-persistence.jar; %LIB%\hibernate-entitymanager.jar;%LIB%\hibernate3.jar;%LIB%\jboss-common.jar; %LIB%\dom4j-1.6.1.jar;%LIB%\hibernate-annotations.jar;%LIB%\commons-logging-1.0.4.jar; %LIB%\cglib-2.1.3.jar;%LIB%\javassist.jar;%LIB%\commons-collections-2.1.1.jar; %LIB%\mysql-connector-java-5.0.3-bin.jar;%LIB%\ehcache-1.2.jar;%LIB%\asm.jar; %LIB%\jta.jar

Read More →

Article on JUnit 4

I’ve published an article about JUnit 4 on DevX : Get Acquainted with the New Advanced Features of JUnit 4. JUnit 4 has changed a lot and it looks like there is much more to come. This article shows you how to migrate from JUnit 3.8 to JUnit 4 and gives you an overview of JUnit 4 new features. An article is never written alone. So first of all I would like to thank my wife Denise who read and corrected a boring technical article that she didn’t understand a word. Second, Lori Piquet from JupiterMedia for his help and expertise in writing articles. And a special thanks to both my friends Alexis Midon and Zouheir Cadi who took a bit of time to review this article. Do not hesitate to post comments.

Read More →

Annotations are great ! Really ?

Do you remember 6/7 years ago. EJBs were the big thing and with them came deployment descriptor written in XML. Then Webapp with their web.xml, and then Enterprise applications with their application.xml. XML was everywhere, XML was cool. Imagine, you can write your Java code, deploy it and after just twist bits and pieces in your XML files. XML, XML… Then we had SAX, DOM, JAXB, Castor, XSL, XSLT, Schemas, DTD… God, life became so flexible. Too flexible ? Of course ! XML has taken over our lives, we all hate XML now. We hate it so much that we started using xDoclet to get rid of it. But now, thanks to Java 5, we are really getting rid of XML and giving up all this XML flexible into more rigid annotations. But it‘s so much better : code and annotations are at the same place, on the same class, on the same method. Much better, easier to read. You see, annotations are so cool that we use them for persistence (Hibernate, JPA…), components (EJB 3), unit testing (JUnit 4), XML (with JAXB 2)… and so on. Yes, I tell you, annotations are great ! And there is no way that in 6/7 years we will end up coding this : @Entity @Name('componentName') @Inheritance @Scope(ScopeType.CONVERSATION) @Logger('loggerName') @TransactionAttribute(NEVER) @Remote({examples.Animal.class}) @ExcludeDefaultInterceptors @NamedQuery(name='findAllAnimals') class Animal extends Creature ( @Id @SequenceGenerator(name='ANIMAL_SEQ', allocationSize=25) @GeneratedValue(strategy=SEQUENCE, generator='ANIM_SEQ') @Column(name='ANIM_ID') private String id @AssociationOverride @Enumerated private Owner owner @Deprecated […]

Read More →

JAXB 2.0 Hello World

For people who have played with JAXB 1.x, JAXB 2.0 has the same beahavior: it can marshall/unmarshall object from/to XML. But the syntax is completly different. It uses all kind of annotations. This blog is just about writing and executing a good old Hello World with JAXB 2.0. First you need to download and install the binary. For the following example you will just need to put jaxb-api.jar and jaxb-impl.jar in your classpath. The following code represents a HelloWorld class with two attributes. The main method creates a HelloWorld object, sets some values, marshalles it to the hello.xml file, displays the xml representation, unmarshalles the xml file into a HelloWord and displays the toString method : import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlRootElement; import; import; @XmlRootElement public class HelloWorld { private String hello; private Integer world; public String getHello() { return hello; } public void setHello(String hello) { this.hello = hello; } public Integer getWorld() { return world; } public void setWorld(Integer world) { = world; } public String toString() { return hello "-" world; } public static void main(String[] args) throws Exception { // Set up file and JAXB context final File file = new File("hello.xml"); JAXBContext context = JAXBContext.newInstance(HelloWorld.class); // Creates a HelloWorld object HelloWorld hw = new HelloWorld(); hw.setHello("Hello !!!"); hw.setWorld(1234); // From a HelloWorld object creates a hello.xml file Marshaller m = context.createMarshaller(); m.marshal(hw, new FileOutputStream(file)); m.marshal(hw, System.out); // From the hello.xml […]

Read More →

Java Day 2006 in Paris

Well, in fact Java Day 2006 wasn’t held in Paris itself but in Versailles, just in front of the castle So, yes, things also happen outside the US. I know, it was just a one day java conferences with only 5 sessions, nothing compare to the four days of Java One and its 188 sessions. But still, we had James Goslings on stage. If you look at the agenda, this is what happened. Welcome Eric Mahé ? Technology Advisor ? Sun Microsystems France Eric, who has been working for 17 years at Sun, introduced the java day and the agenda. After few marketing slides (you always have to thank the sponsors) he joked about Extreme Pixel Programming. The idea is that Eric is not a java programmer, the tool he uses the most is Photoshop and he would like to use it to code some java classes. So he opened Photoshop, dragged & dropped some images, saved it as a raw file, opened the raw file, copied the content and pasted it into a java file in Netbeans. He then executed it, and the image was displayed with animation. He said that the one who finds the trick will win one of its own art work… bets opened. The Next Wave of Java Tools James Gosling ? Chief Technology Officer of Sun’s Developer Products group James arrived on stage and threw some left over t-shirt of Java One at the […]

Read More →

What would be your ideal job?

I‘ve been working in the IT industry for quite a long time now. Mainly in big companies, on big projects where you spend half your time in meetings and the other half writing meeting reports. Through this experience I‘ve met a lot of people who have had different experiences, different projects but I‘ve never met anyone who has had their ideal job during his/her career. There are always management, political, personnel or budget problems which cause the project to turn into a nightmare. When you talk to people, everybody seems to converge towards an ideal situation where innovation, dynamism, professionalism, intelligent management and beauty flow 10 hours a day… but that never happens. As a Java developer, architect or project leader, what would be your ideal job? Working in a big company, an editor, a start-up, self-employed, working in open-source, in a training company? At the office or at home? Part-time or full-time? What kind of industry would fulfil your dreams? Bank, insurance, telecommunications, industry, leisure? What would be the perfect allocation between development, management, training, publishing articles, working for open source, technology watch, learning new things? Or would you quit Java to move to .Net or a deserted island under the sun? While waiting for the magical wand to create the job of our dreams, let’s blog about it.

Read More →

Weblogic cluster life cycle

When you run a weblogic cluster you have to deal with several messages BEA-0001xx . It is then difficult to figure out what is the normal behavior of a cluster and the normal messages to get. Imagine two managed servers ClusterServer1 (listening on port 4001) and ClusterServer2 (port 4002) running on a cluster and sharing heartbeats through the multicast address […]

Read More →

Connection time out. Careful with your threads

Last week we had a bottle neck on our application and it took us several days to find it. So, here is what you should not do. The architecture is as followed : 2 Alteons to spread the load 2 reverse proxy a layer of Firewalls 2 HTTP compressors 4 web server iPlanet (Sun Java Web Server 6.0) a cluster of 40 Weblogic server running on 4 different boxes a database server. Everything running on HP-Ux11. iPlanet only dispatch static pages and images and Weblogic has the presentation (JSP/Servlet) and EJB layers (it does 99% of the work). The problem was that a lot of connections were falling on time out. We kept on focusing on weblogic and controlling the thread and memory activity to see if we had any dead lock of memory leek (there are some JNI calls somewhere). Weblogic wasn‘t doing anything, not under stressed at all. The application was configured to run 2000 concurent users that‘s why each instance of weblogic was running 60 threads (60 threads * 40 instance = 2400). After some days of analysing and twisting weblogic, we remembered that we had a layer of iPlanets on the front. The admin guys were sure that there was no problem with iPlanet because each server was supposed to run 512 threads. It wasn‘t the case. Each instance was configured with 128 thread (128*4 instance = 512). That was why weblogic was doing nothing and […]

Read More →

God is a .Net Programmer

Part of my company‘s job is to create tailored software for clients. They manage to deliver 5–6 a year and producing each one takes between 200–500 days. For the last 2 years they have developed around 80% using the .Net platform and the remaining 20% using Java. Last year I worked for 1 month with a .Net team trying to re-architect their software, but I gave up. Those guys didn‘t know what a Singleton was, nor a framework, nor even a package ! And because I didn‘t know anything about .Net (and still don‘t) I moved to do other things. The other day I was talking to one of the commercial guys and I asked him why my company wasn‘t putting any effort in trying to do more Java. The answer was quick and precise: “We realized that .Net software is 40% cheaper than Java“ (understand faster to develop for the same price). I was about to argue, bring the technical side, the big mistakes that I spotted during my little experience with .Net, talk about the Java community, the open source framework, the well designed architecture I‘ve worked with and so on. When I realized that he was a commercial guy, wearing a suit and a tie, I had the divine inspiration that made me reply: “God created the universe, the planet and Man in just 7 days. And you can see the mess. Imagine if he had 40% […]

Read More →