dimanche 11 mai 2008

Rich Internet Application: Development Pet Store 2.0 using GWT and ExtJS.


Google Web toolkit(GWT) is a powerful technology provided by Google Inc, It allows Java developers to write AJAX-enabled web application in the Java programming language and generate a highly optimized JavaScript.

Ext JS, the Java script library for building rich internet application interested by GWT technology, provides an add-on library, EXT GWT, to let developers writing Ext JS components in Java.

In this article, I will show you the architecture used to add presentation components on the top of the Pet Store 2.0 persistence layer using Ext GWT and discuss how the communication between layers could be handled.


To build and run the sample, you need the following softwares:

Getting started:

To start developing Rich Internet application with Ext GWT, the first step is to write the entire application in Java programming language using Ext GWT library. GWT comes with an embedded browser and debugger, so you can run/debug your web application.

Note that all Java components will be converted as client side components into JavaScript language. Therefore, you can’t write server side components such as servlet in your GWT application, but you could write how the interaction with these components could be happened. GWT supports remote procedure call for passing Java objects to and from a server over http, so you can get/submit Data through RPC(Remote Procedure Call) or by http requests.

In this sample, we only use http Data Request to interact with server.

High Level Architecture Diagram:

To make it easier to understand RIA application development with Ext GWT, the diagram below details the architecture used for building this sample and for any kind of application using GWT.


In this article, we have seen together a kind of innovative architecture used for building RIA applications. This architecture is based on GWT to generate Ext JS components from Java code and use http requests to interact with server.



mardi 6 mai 2008

Rich Client Platform: Development Pet Store 2.0 using Eclipse RCP and JBoss.


In this article, I will show you how the combination of Eclipse RCP and EJB3 allow developers to build a rich, performed and distributed application. I will assume that you understand the basics of technologies mentioned above, and I will only explain the architecture used to efficiently handle the communication between the desktop application and the server.

This article is based on previous articles:


To build and run the sample, you need the following software:

High Level Architecture Diagram:

The diagram below details the architecture used for building this sample. It shows the interaction between RCP Application and server side components. Client could discover and lookup services via JNDI as service registry.


Configuration always depends on the application server, but it is quite the same.
I details below the configuration needed to lookup services via JNDI in JBoss server.

  • JBoss Client Library : Add jboss-all-client in the classpath.

  • PetStore client Interfaces : Add PetStore client libray in the classpath

  • JNDI parameters :

+ java.naming.provider.url=localhost:1099


In this article, we have seen together how we can access to distributed components by desktop application built using Eclipse RCP.



lundi 5 mai 2008

Deploying Java Pet Store 2.0 on JBOSS using Eclipse IDE


The java Pet store 2.0 is a reference application for building Ajax-enabled web application on Java EE 5. It is provided by the Java blueprints program at Sun Microsystems.
You can find more details from https://blueprints.dev.java.net/petstore/

Many people ask about running PetStore 2.0 with JBOSS server application or another JEE server that could be different from Sun server.
This tutorial is for showing you how it is possible to run PetStore 2.0 with JBoss and discuss the changes needed.


Getting started:

JBoss version 5.0, is recently a Java EE 5 compatible application server. Therefore, we don’t need to refactor the code in order to disable Java 5 features like generic types and dependency injection using annotations. However, you have to paid attention on the deployment.
Jboss recommends using the EAR file as recommended way to deploy application. So, we need to separate the persistence layer from the other layers in order to create a jar file which contains the EJB module and a war file containing the Web module.
To deploy PetStore application, you need to create three eclipse projects.

First-Step: Creation an EJB Project:

To create a new EJB project:

  1. In the J2EE perspective, select File > New > Other > EJB > EJB Project. The New EJB Project wizard opens.

  2. In the Project Name field, type a name for the EJB project.

  3. Optional: To use a different workspace directory for your EJB project, modify the settings for Project contents.

    Important: If you specify a non-default project location that is already being used by another project, the project creation will fail.

  4. In the Target runtime drop-down list, select the application server that you want to target for your development. This selection affects the compilation and runtime settings by modifying the class path entries for the project. Use the New button if a target runtime does not exist, or if you want to use a different one
Once the project is created, import entities which are located in src folder of PetStore.

Changes needed:

  • Add a persistence.xml into the META-INF directory:

<?xml version="1.0" encoding="UTF-8"?>

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

<persistence-unit name="PetstorePu">



<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>




  • Setup the DB, using the HSQL Database Manager, by executing the petstore.sql script located under the setup/sql/javadb/
Second step: Creation a Dynamic Web project:

To create a new dynamic Web project, complete the following steps:

  • Open the J2EE perspective.

  • In the Project Explorer, right click on Dynamic Web Projects, and select New > Dynamic Web Project from the context menu. The New Dynamic Web Project wizard starts.

  • Follow the project wizard prompts.

Once the project is created, import all classes located in src folder of PetStore except entities classes.

Changes needed:

  • Remove the resource-ref in web.xml, it’s no longer needed.

  • Remove duplicated context-param « com.sun.faces.verifyObjects »

Third step: Creation an Enterprise Application project:

To create a J2EE enterprise application project:

  1. In the J2EE perspective, click File > New > Project > J2EE > Enterprise Application Project.

  2. In the Project Name field, type a name for the new project.

  3. To change the default project location, clear the Use default check box under Project contents and select a new location with the Browse button.

  4. In the Target runtime field, select the target runtime for the project. You can click the New button to create a new runtime for the project to use.

  5. On the JEE modules, select the two projects created above.

Finally, select the EAR project and click Run as>run on server.

Download :