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 download the 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:
the e-commerce site itself (Yaps Pet Store) is in the yaps directory
the BarkBank web service to validate credit cards in the barkbank directory
the PetEx web service Web in the petex directory
As you can see it in the images below, each one of these applications is made up of sub-directories.
Each sub-directory contains specific files:
build: contains the files to be deployed in GlassFish (war and ear)
classes: directory containing the bytecode of the application
config: contains the files to configure the application
generated: Java classes generated for the web services
resources: Web pages and images of the web site
src: this directory contains the Java source files of the application
WEB-INF: contains the files to configure the web application
Install the tools
Before running the application, make sure that you have the needed tools installed:
JDK
Install a version of the JDK equal or higher than 1.5_11
Install a version of Glassfish equal or higher than V2b41
Download the jar file and then run the commande java -Xmx256m -jar fileName.jar
Set the GLASSFISH_HOME variable
Enter the command %GLASSFISH_HOME%/ant -f setup.xml to end the GlassFish setup
Add the %GLASSFISH_HOME%/bin directory in your PATH
Set up the servers
Now you have to setup GlassFish and the database. Ant admin tasks are in the %PETSTORE_HOME%/admin.xml file
Create the petstore domain in GlassFish using the following passwords (admin port is 8282)
%GLASSFISH_HOME%/\bin/\asadmin create-domain --adminport 8282 --user admin --savemasterpassword=true --instanceport 8080 petstore
Please enter the admin password>adminpwd
Please enter the admin password again>adminpwd
Please enter the master password>masterpwd
Please enter the master password again>masterpwd
Using port 8282 for Admin.
Using port 8080 for HTTP Instance.
Using default port 7676 for JMS.
Using default port 3700 for IIOP.
Using default port 8181 for HTTP_SSL.
Using default port 3820 for IIOP_SSL.
Using default port 3920 for IIOP_MUTUALAUTH.
Using default port 8686 for JMX_ADMIN.
Domain petstore created.
You will then see the %GLASSFISH_HOME%/domains/petstore directory
(If later you want to delete this domain, enter ant -f admin.xml delete-domain or asadmin delete-domain petstore)
Start Glassfish by entering %PETSTORE_HOME%/ant -f admin.xml start-domain
On the logging page, click on the "Log Levels" tab
At the bottom of the page you'll see the "Additional Module Log Level Properties" section
You should see the following loggers : com.yaps.petstore, com.barkbank et com.petex
Deploy the application
Now that the servers are setup, you have to deploy the applications on the server.
Déploy the BarkBank application
Build the application with %PETSTORE_HOME%/ant barkbank-build. This will compile the application, generate the web services les artefacts and package the application in the %PETSTORE_HOME%/BarkBank/build/barkbank.war file
Deploy the application on the server with %PETSTORE_HOME%/ant barkbank-deploy. To check that the deployment is done go to http://localhost:8080/barkbank/
Déployez l'application PetEx
Build the application with %PETSTORE_HOME%/ant petex-build.This will compile the application, generate the web services les artefacts and package the application in the %PETSTORE_HOME%/PexEx/build/petex.war file
Deploy the application on the server with %PETSTORE_HOME%/ant petex-deploy. To check that the deployment is done go to http://localhost:8080/petex/
Déployez l'application Yaps
Build the application with %PETSTORE_HOME%/ant yaps-build. This will compile the application, generate the web services les artefacts and package the application in the %PETSTORE_HOME%/Yaps/build directory
Deploy the application on the server with %PETSTORE_HOME%/ant yaps-deploy. This task deploys the application and adds data to the database. To check that the deployment is done go to http://localhost:8080/petstore/
Use the application
Once the three applications deployed, you can go to http://localhost:8080/petstore/. Look at the animals catalog, create your own account or log on as job/job. Buy some pets, create an order and you'll use the external web services of BarkBank (to validate bredit cards) and PetEx.
To run the Swing application use the %PETSTORE_HOME%/ant run-client task
Comments: 0