Part 6: Glassfish V3 Pet Catalog sample DEMO in VM Template - SW Installation

OpenSolaris 200906 JeOS Prototype was designed as PURE CLI enviroment providing main building stone for creation of Virtual Appliances or VM Templates

In this example I will DEMOnstrate creation of Evaluation type Virtual Appliance / VM Template which will leveradge OpenSolaris 200906 JeOS prototype and just in Dec/09 released Glassfish v3, Java EE 6 and Netbeans 6.8 with simple Java EE 6 demo. This entry is part of Virtual Appliances & OVF workshop.

New Glassfish V3 introduce an unique network repository based modular structure, so we can more easily create really simple initial DEMO setup which user can extend by installation more samples right from Glassfish V3 repository or from Netbeans GUI.

Step 2: Add layered software

Step 2g: Install Java EE 6 Pet Catalog sample from NetBeans 6.8 IDE (Video)

This Pet Catalog app explains a web application that uses JSF 2.0, Java EE 6, GlassFish and MySQL.

1. Get on Java EE 6 Pet Catalog sample

Java EE 6 Pet Catalog sample:

Carol McDonald blog TechDays sample Java EE 6 Pet Catalog with GlassFish v3 preview and MySQL

Java EE 5 Pet Catalog sample:

Ed Ort's and Carol McDonald tech tip in GlassFish and MySQL, Part 2: Building a CRUD Web Application With Data Persistence

Backup is on ~/unbundled/PetSample in case then links will not be avaiable in future

osol@osol-jeos:~/unbundled$ find ./PetCatalogSample -name \*.html
  ./PetCatalogSample/JavaEE5/GlassFish and MySQL, Part 2: Building a CRUD Web Application With Data Persistence.html
  ./PetCatalogSample/JavaEE6/Java EE 6 Pet Catalog with GlassFish v3 preview and MySQL.html
  ./PetCatalogSample/datasrource/LAB-4923: Spring Framework and JPA.html

2. Install MySQL Connector / J

Sample use MySQL database, so we need to install latest MySQL Connector-J

Using MySQL With Java

MySQL Connector-J for MySqQL 5.1

osol@osol-jeos:~/unbundled/glassfishv3$ cd /tmp
osol@osol-jeos:/tmp$  wget
Length: 3,871,044 (3.7M) [application/zip]

osol@osol-jeos:/tmp$ unzip

osol@osol-jeos:/tmp$ pfexec cp  ./mysql-connector-java-5.1.10/\*.jar  /usr/java/jre/lib/ext

osol@osol-jeos:/tmp$ pfexec chown root:bin /usr/java/jre/lib/ext/mysql-connector-java-5.1.10-bin.jar

osol@osol-jeos:/tmp$ rm -r ./mysql-connector-java-5.1.10
osol@osol-jeos:/tmp$ rm

3. Start Glassfish and MySQL servers

osol@osol-jeos:~$ cd ~/unbundled/webstack16/
osol@osol-jeos:~/unbundled/webstack16$  ./bin/sun-mysql51 start
Starting mysql51                   OK

osol@osol-jeos:~$ cd ~/unbundled/glassfishv3/
osol@osol-jeos:~/unbundled/glassfishv3$ ./bin/asadmin start-domain
Waiting for DAS to start ......
Started domain: domain1
Domain location: /export/home/osol/unbundled/glassfishv3/glassfish/domains/domain1
Log file: /export/home/osol/unbundled/glassfishv3/glassfish/domains/domain1/logs/server.log
Admin port for the domain: 4848
Command start-domain executed successfully.

4. Allow use OSOL to login into MySQL from localhost with password

By default MySQL 5.1 in WebStack configuration we can login from localhost wihout password,
because in VM Ttemplate we use a IP address from DHCP, we need to allow also connections from LOCALHOST with password too.

osol@osol-jeos:~$ cd ~/unbundled/webstack16/

osol@osol-jeos:~/unbundled/webstack16$ ./bin/mysql -u root -p
Enter password:

Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.

mysql> grant all privileges on \*.\* to osol@localhost  identified by 'justone1';
Query OK, 0 rows affected (0.01 sec)

mysql> quit

osol@osol-jeos:~/unbundled/webstack16$ ./bin/mysql -u osol -p
Enter password:

mysql> quit

5. Install Netbeans 6.8 platform with Java EE 6 support

Unfortunately for Netbeans 6.8 remotes usage of Glassfish V3 / Java EE 6 you need a to donwload vreison withintegrtaed GlassfishV3,
local instance of same version is needed to be able to compile/build jar's which will be after deployed later

On Windows host you get 210MB download size, you don't need any MySQL files, JDBC driver is already part of IDE.

6. Load a Pet Catalog sample and follow up Videos

You need a actual PUBLIC IP address of JeOS instance fro remote deployment, in samples I use, I get it like this:

osol@osol-jeos:~/unbundled$ dladm show-ether
LINK            PTYPE    STATE    AUTO  SPEED-DUPLEX                    PAUSE
e1000g0         current  up       yes   1G-f                            bi

osol@osol-jeos:~/unbundled$ ifconfig e1000g0
e1000g0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 index 2
        inet netmask fffffe00 broadcast

In Netbeans 6.8 IDE

  • Open pet catalog catalog project
  • Register MySQL Server
  • Create petcatalog MySQL databe
  • Open JDBC/petcatalog (created automatically)
  • Load SQL data to petcatalog database.

In Glassfish admin

  • Create a petcatalog MySQL connection pool (local connection using localhost)
  • Create a JDBC/petcatalog MySQL

In Netbeans IDE

  • Build, Deploy and Test petcatalog application

Videos of setup:

PetCatalog in NetBeans68 on Remote GFv3 MySQL51 Res: 1024x768 (27MB)
PetCatalog in NetBeans68 on Remote GFv3 MySQL51 Res: 640x480 (15MB)

7. Stop Glassfish and MySQL servers

osol@osol-jeos:~$ cd ~/unbundled/glassfishv3/
osol@osol-jeos:~/unbundled/glassfishv3$ ./bin/asadmin stop-domain
Waiting for the domain to stop ....
Command stop-domain executed successfully.

osol@osol-jeos:~$ cd ~/unbundled/webstack16/
osol@osol-jeos:~/unbundled/webstack16$  ./bin/sun-mysql51 stop
Stopping mysql51                   OK

6. Check used space after Pet Catalog Sample installation

6a. Check ZFS used space after Pet Catalog Sample installation

osol@osol-jeos:~$ zfs list
NAME                               USED  AVAIL  REFER  MOUNTPOINT
rpool                             2.25G  5.56G  83.5K  /rpool
rpool/ROOT                         862M  5.56G    19K  legacy
rpool/ROOT/opensolaris             862M  5.56G   862M  /
rpool/dump                         384M  5.56G   384M  -
rpool/export                       545M  5.56G    20K  /export
rpool/export/home                  545M  5.56G    20K  /export/home
rpool/export/home/osol             545M  5.56G  57.5K  /export/home/osol
rpool/export/home/osol/unbundled   545M  5.56G   545M  /export/home/osol/unbundled
rpool/swap                         512M  6.06G    20K  -

osol@osol-jeos:~$ df -h
Filesystem                                       Size  Used Avail Use% Mounted on
rpool                                               5.6G   84K  5.6G   1% /rpool
                                                       6.5G  862M  5.6G  14% /
rpool/export                                     5.6G   20K  5.6G   1% /export
rpool/export/home                            5.6G   20K  5.6G   1% /export/home
                                                       5.6G   58K  5.6G   1% /export/home/osol
                                                       6.1G  546M  5.6G   9% /export/home/osol/unbundled

6b. Check Virtual Disk and Archive sizes after Pet Catalog Sample installation

osol@osol-jeos:~/unbundled/webstack16$  pfexec init 0

Virtual Disk size grow to 1611MB and with 7Z ultra compression size is now 378MB

Post a Comment:
  • HTML Syntax: NOT allowed

Hands-on experience with Virtualization


« April 2014