Today you can find many articles showing Java EE 6 examples and new features. However it's missing a complete tutorial showing how to design and deploy a sample Java EE 6 application on JBoss AS 6. While it's not intended to be the "the right" way to design Java EE 6 applications, this tutorial can be helpful to show how some cool Java EE 6 features can combine to produce a simple but effective application.


The aim of this article will be to upgrade the Java EE 5 "AppStore" application, developed on JBoss AS 5, to Java EE 6. (You can download  the code for the earlier AppStore from Packtpub web site, or simply buy the book :-) )

The older EE 5 AppStore application was originally an Enterprise application made up of a Web Tier and EJB Tier.
The new EE 6 AppStore application is a Web application containing Web components, the Entity Models and the EJBs.


In order to set up this application, we will need at first to set up the Database schema.
java ee 6 tutorial
This schema was designed for MySQL 5. You will need just to create a schema named "Appstore" and
grant all privileges to the user "jboss"

CREATE DATABASE appstore;

USE appstore;

CREATE USER 'jboss'@'localhost' IDENTIFIED BY 'jboss';

GRANT ALL PRIVILEGES ON appstore TO  'jboss'@'localhost' WITH GRANT OPTION;

CREATE TABLE  `appstore`.`customer` (
`ID` int(10) unsigned NOT NULL auto_increment,
`NAME` varchar(45) NOT NULL,
`COUNTRY` varchar(45) NOT NULL,
PRIMARY KEY  (`ID`)
) ENGINE=InnoDB;
CREATE TABLE  `appstore`.`item` (
`ID` int(10) unsigned NOT NULL auto_increment,
`PRODUCT` varchar(45) default NULL,
`PRICE` int(11) default NULL,
`QUANTITY` int(11) default NULL,
`CUSTOMER_ID` int(10) unsigned NOT NULL,
PRIMARY KEY  (`ID`),
KEY `FK_orders` (`CUSTOMER_ID`),
CONSTRAINT `FK_orders` FOREIGN KEY (`CUSTOMER_ID`) REFERENCES `customer` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;


Once done with the DB schema, we will create a Datasource file pointing to the schema AppStore and
drop into the "deploy" folder of JBoss AS 6.

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
    <local-tx-datasource>
        <jndi-name>MySqlDS</jndi-name>
        <connection-url>jdbc:mysql://localhost:3306/appstore</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <user-name>jboss</user-name>
        <password>jboss</password>
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
        </exception-sorter-class-name>
        <metadata>
            <type-mapping>mySQL</type-mapping>
        </metadata>
    </local-tx-datasource>
</datasources>
0
0
0
s2smodern

W

i

l

d

F

l

y

 

c

h

e

a

t

s

h

e

e

t